#include "Fenetre.h"


/*Fonction qui affiche une fenetre quelconque                                                                               */
void    afficheFenetre(GtkWindow*window)
{
    assert(window!=NULL);
   gtk_widget_show_all((GtkWidget*)window);
}

void    afficheFenetreIdentification()
{
    gtk_widget_show_all(GTK_WIDGET(FenIdentification));
}

void    afficheFenetreEtudiant()
{
    gtk_widget_show_all(GTK_WIDGET(FenEtudiant));
}
/****************************************************************************************************************************/

/*Charge l'ensemble des fenetres de l'interface dans une structure Fenetre.                                                 */
void    chargerInterface()
{

    listFenetres->fenetreEnseignant=(GtkWindow*)gtk_builder_get_object(p_builder,"fenetre_enseignant");

    listFenetres->fenetreGererUe=(GtkWindow*)gtk_builder_get_object(p_builder,"fenetre_gestion_ue");

    listFenetres->fenetreListUeEns=(GtkWindow*)gtk_builder_get_object(p_builder,"fenetre_list_ue_ens");

}

/****************************************************************************************************************************/

/*Crée et initialise tout les éléments nécessaires à l'interface, Cela en parsant un fichier XML Glade. Puis lance les focntion
 de connexion aux callback et l'affichage de la fenetre d'identification                                                       */
void  deployerUI(int argc,char**argv)
{
    listFenetres=calloc(1,sizeof(Fenetre));

    p_builder=NULL;
    p_builder=gtk_builder_new();
    p_err=NULL;

    gtk_builder_add_from_file (p_builder,srcXML , &(p_err));

    chargerInterface();
    lancerUI();
}

/****************************************************************************************************************************/


/*Affiche l'interface graphique, uniquement la fenetre d'identification                                                         */
void    lancerUI()
{
    initFenIdentification();

    afficheFenetreIdentification();
}

/****************************************************************************************************************************/

void lancerApplicationEtudiant(Etu*etudiant)
{
    preparerFenetreEtudiant(etudiant);

    connectSignal_FenetreEtudiant();

    char addimage[100];
    sprintf(addimage, "data/%d.jpg",etudiant->numEtu);

    gtk_image_set_from_file(GTK_IMAGE(image_Etudiant),addimage);
     /*gtk_widget_set_size_request(image_Etudiant,100,100);*/
    gtk_window_fullscreen(GTK_WINDOW(FenEtudiant));
    gtk_window_set_resizable(GTK_WINDOW(FenEtudiant),TRUE);
    afficheFenetreEtudiant();
}


/** @brief lancerApplication
  *
  * @todo: document this function
  */
void lancerApplication(Login *log)
    {
    if(log!=NULL   &&  log->identifiant!=NULL  &&  log->type>0)
        {
        if(log->type==1)
            {
            Etu *  etudiant=recEtuParCode(atoi(log->identifiant));
            if(etudiant!=NULL)
                {
                lancerApplicationEtudiant(etudiant);


                }
            else
                {
                printf("Erreur: impossible de lancer l'application: etudiant introuvable");
                }
            }
        else if (log->type==2)
            {
            Ens*ens=recEnsParCode(atoi(log->identifiant));
                   if(ens!=NULL)
                {

                connectSignal_FenetreEnseignant();

                connectSignal_FenetreListUeEns();

                lancerApplicationEnseignant(ens);
                return ;
                }
            else
                {
                printf("Erreur: impossible de lancer l'application: enseignant introuvable");
                }
            return ;
            }
        else if(log->type==3)
            {
           lancerApplicationAdministrateur() ;
            }
        else if(log->type==4)
            {
            return ;
            }
        else
            {
            return ;
            }
        }
    else
        {
        GtkWidget *dialog;


        dialog = gtk_message_dialog_new_with_markup (   GTK_WINDOW(FenIdentification),
                 GTK_DIALOG_DESTROY_WITH_PARENT,
                 GTK_MESSAGE_ERROR,
                 GTK_BUTTONS_CLOSE,
                 "L'application a reconnu vos identifiants mais elle n'arrive pas à ce lancer, veuillez réessayer");
        gtk_dialog_run (GTK_DIALOG (dialog));
        gtk_widget_destroy (dialog);

        }
    }

void    cb_init_tabUeEtu(GtkWidget *widg, GdkEvent *event, gpointer message)
{


    char*c_numEtu=(char*)gtk_widget_get_name(widg);
    int numEtu=atoi(c_numEtu);
    numEtuSel=numEtu;
    Etu*etu=recEtuParCode(numEtu);
    TabIP   *   tabIp=recIpParEtudiant(etu);

    gtk_widget_destroy(table_ue_etu);
    table_ue_etu=(GtkWidget*)gtk_table_new(1,1,TRUE);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal),table_ue_etu,0,1,4,5);
    gtk_table_resize(GTK_TABLE(table_ue_etu),tabIp->nbIP+1,5);

    GtkWidget *col1=gtk_label_new("Séquence");
    GtkWidget *col2=gtk_label_new("Code UE");
    GtkWidget *col3=gtk_label_new("Intitulé");
    GtkWidget *col4=gtk_label_new("Annee");
    GtkWidget *col5=gtk_label_new("Semestre");

    gtk_table_attach_defaults(GTK_TABLE(table_ue_etu),col1,0,1,0,1);
    gtk_table_attach_defaults(GTK_TABLE(table_ue_etu),col2,1,2,0,1);
    gtk_table_attach_defaults(GTK_TABLE(table_ue_etu),col3,2,3,0,1);
    gtk_table_attach_defaults(GTK_TABLE(table_ue_etu),col4,3,4,0,1);
    gtk_table_attach_defaults(GTK_TABLE(table_ue_etu),col5,4,5,0,1);

    int i=0;
    while(i<tabIp->nbIP)
    {

        UE*ue=recUEParCode(tabIp->tabIp[i]->codeUe);
        assert(ue!=NULL);
        char*   c_seq=calloc(1,sizeof(char));
        sprintf(c_seq,"%d",ue->sequence);
        GtkWidget *sequence_label=gtk_label_new(c_seq);

        char*   c_code_ue=calloc(5,sizeof(char));
        sprintf(c_code_ue,"%d",ue->codeUE);
        GtkWidget *code_ue_label=gtk_label_new((gchar*)c_code_ue);


        GtkWidget *intitule_label=gtk_label_new((gchar*)ue->intitule);

        char*   c_annee=calloc(4,sizeof(char));
        sprintf(c_annee,"%d",tabIp->tabIp[i]->annee);
        GtkWidget *annee_label=gtk_label_new((gchar*)c_annee);

        char*   c_semestre=calloc(1,sizeof(char));
        sprintf(c_semestre,"%c",tabIp->tabIp[i]->semestre);

        GtkWidget *semestre_label;
        if(strcmp(c_semestre,"1")==0)
        {
        semestre_label=gtk_label_new((gchar*)"Automne");

        }
        else if(strcmp(c_semestre,"2")==0)
        {
        semestre_label=gtk_label_new((gchar*)"Printemps");

        }
        else
        {
        semestre_label=gtk_label_new((gchar*)"----");
        }




        gtk_table_attach_defaults(GTK_TABLE(table_ue_etu),sequence_label,0,1,i+1,i+2);
        gtk_table_attach_defaults(GTK_TABLE(table_ue_etu),code_ue_label,1,2,i+1,i+2);
        gtk_table_attach_defaults(GTK_TABLE(table_ue_etu),intitule_label,2,3,i+1,i+2);
        gtk_table_attach_defaults(GTK_TABLE(table_ue_etu),annee_label,3,4,i+1,i+2);
        gtk_table_attach_defaults(GTK_TABLE(table_ue_etu),semestre_label,4,5,i+1,i+2);

        i++;
    }
    detTab((void**)&tabIp);
    detEtu(&etu);

    gtk_widget_show_all(table_ue_etu);
}


void  preparerFenetreIp(Ens*ens)
{
    initFenIp();
    TabEtu  *   tabEtu=recListEtuParEns(ens);
    if(tabEtu->nbEtu>0)
    {
        gtk_table_resize(GTK_TABLE(table_etu),tabEtu->nbEtu*2,1);
        int i=0;
        while(i<tabEtu->nbEtu)
        {

            GtkWidget   *etuBut=gtk_button_new();
            char*textlabel=calloc(50,sizeof(char));
            char*   c_numEtu=calloc(20,sizeof(char));
            sprintf(c_numEtu,"%d",tabEtu->tabEtu[i]->numEtu);
            strcat(textlabel,c_numEtu);
            strcat(textlabel,"  ");
            strcat(textlabel,tabEtu->tabEtu[i]->nomEtu);
            strcat(textlabel,"  ");
            strcat(textlabel,tabEtu->tabEtu[i]->prenomEtu);
            gtk_button_set_label(GTK_BUTTON(etuBut),(gchar*)textlabel);
            gtk_widget_set_name(etuBut,c_numEtu);
            g_signal_connect(etuBut,"clicked",G_CALLBACK(cb_init_tabUeEtu),etuBut);

            gtk_table_attach_defaults(GTK_TABLE(table_etu),etuBut,0,1,i,i+1);

            i++;
        }
    }
    else
    {
        gtk_table_resize(GTK_TABLE(table_etu),1,1);
        GtkWidget *label=gtk_label_new("Vous n'ètes responsable d'aucun étudiant");
        gtk_table_attach_defaults(GTK_TABLE(table_etu),label,0,1,0,1);

    }

    TabUe  *tabUe =recToutUe();

    gtk_table_resize(GTK_TABLE(table_ue),tabUe->nbUe,1);
    int i=0;
    while(i<tabUe->nbUe)
    {
        char*textlabel=calloc(50,sizeof(char));
        char*   c_codeUe=calloc(20,sizeof(char));
        sprintf(c_codeUe,"%d",tabUe->tabUe[i]->codeUE);

        char*   c_seq=calloc(2,sizeof(char));
        sprintf(c_seq,"%d", tabUe->tabUe[i]->sequence);

        strcat(textlabel,c_codeUe);
        strcat(textlabel,"  ");
        strcat(textlabel,tabUe->tabUe[i]->intitule);
        strcat(textlabel,"  Seq: ");
        strcat(textlabel,c_seq);
        GtkWidget   *ueBut=gtk_check_button_new_with_label((gchar*)textlabel);
        gtk_widget_set_name(ueBut,c_codeUe);
        gtk_table_attach_defaults(GTK_TABLE(table_ue),ueBut,0,1,i,i+1);

        i++;
    }
    detTab((void**)&tabEtu);
    detTab((void**)&tabUe);
}


/*****************************************/

void preparerFenetreEtudiant(Etu  *   etu)
    {
    initFenEtudiant();
    char *  nomEtu=etu->nomEtu;
    char*   prenomEtu=etu->prenomEtu;
    int numEtu=etu->numEtu;
    TabUe*  tabUe=recUeParEtu(etu);
    TabIP*  tabIp=recIpParEtudiant(etu);
    TabEnseignement *   tabEnseignement=recEnseignementParEtu(etu);

    gtk_label_set_text (label_nomEtu_Etudaint   ,(gchar*)(nomEtu));
    gtk_label_set_text (label_prenomEtu_Etudaint,(gchar*)(prenomEtu));
    char*test=calloc(20,sizeof(char));
    sprintf(test,"%d",numEtu);
    gtk_label_set_text (label_numEtu_Etudaint   ,(gchar*)test);


    gtk_table_resize(GTK_TABLE(table_ip_Etudiant),tabUe->nbUe+1,7);
    if(tabUe->nbUe>0    &&  tabUe!=NULL)
    {
        GtkWidget *col1=gtk_label_new("Séquence");
        GtkWidget *col2=gtk_label_new("Code UE");
        GtkWidget *col3=gtk_label_new("Intitulé");
        GtkWidget *col4=gtk_label_new("Annee");
        GtkWidget *col5=gtk_label_new("Semestre");
        GtkWidget *col6=gtk_label_new("Groupe");
        GtkWidget *col7=gtk_label_new("Responsable de l'UE");
        gtk_table_attach_defaults(GTK_TABLE(table_ip_Etudiant),col1,0,1,0,1);
        gtk_table_attach_defaults(GTK_TABLE(table_ip_Etudiant),col2,1,2,0,1);
        gtk_table_attach_defaults(GTK_TABLE(table_ip_Etudiant),col3,2,3,0,1);
        gtk_table_attach_defaults(GTK_TABLE(table_ip_Etudiant),col4,3,4,0,1);
        gtk_table_attach_defaults(GTK_TABLE(table_ip_Etudiant),col5,4,5,0,1);
        gtk_table_attach_defaults(GTK_TABLE(table_ip_Etudiant),col6,5,6,0,1);
        gtk_table_attach_defaults(GTK_TABLE(table_ip_Etudiant),col7,6,7,0,1);

        int i=0;
        while(i<tabUe->nbUe)
        {
            int j=0;
            while(tabUe->tabUe[i]->codeUE!=tabIp->tabIp[j]->codeUe  &&  j<tabIp->nbIP)
            {
                j++;
            }
            char*   c_seq=calloc(1,sizeof(char));
            sprintf(c_seq,"%d",tabUe->tabUe[i]->sequence);
            GtkWidget *sequence_label=gtk_label_new(c_seq);

            char*   c_code_ue=calloc(5,sizeof(char));
            sprintf(c_code_ue,"%d",tabUe->tabUe[i]->codeUE);
            GtkWidget *code_ue_label=gtk_label_new((gchar*)c_code_ue);


            GtkWidget *intitule_label=gtk_label_new((gchar*)tabUe->tabUe[i]->intitule);

            char*   c_annee=calloc(4,sizeof(char));
            sprintf(c_annee,"%d",tabIp->tabIp[j]->annee);
            GtkWidget *annee_label=gtk_label_new((gchar*)c_annee);

            char*   c_semestre=calloc(1,sizeof(char));
            sprintf(c_semestre,"%c",tabIp->tabIp[j]->semestre);

            GtkWidget *semestre_label;
            if(strcmp(c_semestre,"1")==0)
            {
                semestre_label=gtk_label_new((gchar*)"Automne");
            }
            else if(strcmp(c_semestre,"2")==0)
            {
                semestre_label=gtk_label_new((gchar*)"Printemps");
            }
            else
            {
                semestre_label=gtk_label_new((gchar*)"----");
            }

            char*   c_groupe=calloc(1,sizeof(char));
            sprintf(c_groupe,"%c",tabIp->tabIp[j]->groupe);
            GtkWidget *groupe_label=gtk_label_new((gchar*)c_groupe);

            char*   respue=calloc(30,sizeof(char));
            Ens*ens=recResponsableUe(tabUe->tabUe[i]);

            if(ens!=NULL)
            {
                strcat(respue,ens->nomEns);
                strcat(respue," ");
                strcat(respue,ens->prenomEns);
                detEns(&ens);
            }
            else
            {
                strcat(respue,"Auncun responsable");
            }

            GtkWidget *resp_ue_label=gtk_label_new((gchar*)respue);

            gtk_table_attach_defaults(GTK_TABLE(table_ip_Etudiant),sequence_label,0,1,i+1,i+2);
            gtk_table_attach_defaults(GTK_TABLE(table_ip_Etudiant),code_ue_label,1,2,i+1,i+2);
            gtk_table_attach_defaults(GTK_TABLE(table_ip_Etudiant),intitule_label,2,3,i+1,i+2);
            gtk_table_attach_defaults(GTK_TABLE(table_ip_Etudiant),annee_label,3,4,i+1,i+2);
            gtk_table_attach_defaults(GTK_TABLE(table_ip_Etudiant),semestre_label,4,5,i+1,i+2);
            gtk_table_attach_defaults(GTK_TABLE(table_ip_Etudiant),groupe_label,5,6,i+1,i+2);
            gtk_table_attach_defaults(GTK_TABLE(table_ip_Etudiant),resp_ue_label,6,7,i+1,i+2);

            i++;
            }
    }
    else
    {
        gtk_table_attach_defaults(GTK_TABLE(table_ip_Etudiant),gtk_label_new("Vous êtes inscrit à aucune UE"),0,7,0,1);
    }

    char   *tabtext;
    if(tabEnseignement!=NULL)
    {
        tabtext=calloc(50*tabEnseignement->nbEnseignement,sizeof(char));
        if(tabEnseignement->nbEnseignement>0)
        {
            int cpt=0;
            while(cpt<tabEnseignement->nbEnseignement)
            {
                char*c_date=NULL;
                c_date=calloc(20,sizeof(char));
                strcpy(c_date,tabEnseignement->tabEnseignement[cpt]->date);

                if(estUneDateDeLaSemaine(c_date)==0)
                {
                    strcat(tabtext,"\n");
                    strcat(tabtext,getEnseignementText(tabEnseignement->tabEnseignement[cpt]," "));
                }
                cpt++;
            }
        }
        else
        {
            tabtext="Vous n'avez aucun cours de prévu";
        }

    }
    else
    {
        tabtext="Vous n'avez aucun cours de prévu";
    }

    strcat(tabtext,"\0");

    GtkTextBuffer*buf=gtk_text_buffer_new(NULL);

    gtk_text_buffer_set_text(buf,tabtext,-1);
    gtk_text_view_set_buffer(textview_Etudiant,buf);

    gtk_table_resize(GTK_TABLE(table_tomuss_Etudiant),tabUe->nbUe+1,1);
    gtk_table_set_homogeneous(GTK_TABLE(table_tomuss_Etudiant),FALSE);
    initEtuTableTomuuss(etu,GTK_TABLE(table_tomuss_Etudiant),tabUe);

    detTab(((void**)&tabUe));
    detTab(((void**)&tabIp));
    detTab(((void**)&tabEnseignement));

}
/****************************************/

void    preparerFenetreEnseignant(Ens*  ens)
{

    char *  nomEns=ens->nomEns;
    char*   prenomEns=ens->prenomEns;
    int numEns=ens->numEns;
    TabUe*  tabUe=recUeEnseigne(ens);
    TabEnseigne*tabEnseigne=recEnseigne(ens);
    TabEnseignement *   tabEnseignement=recEnseignementParEnseignant(ens);

    gtk_label_set_text (
        GTK_LABEL (gtk_builder_get_object (p_builder, "label_nom_enseignant")),(gchar*)(nomEns));
    gtk_label_set_text (
        GTK_LABEL (gtk_builder_get_object (p_builder, "label_prenom_ens")),(gchar*)(prenomEns));
    char*test=calloc(20,sizeof(char));
    sprintf(test,"%d",numEns);
    gtk_label_set_text (
    GTK_LABEL (gtk_builder_get_object (p_builder, "label_identifiant_enseignant")),(gchar*)test);



    GtkTable *tableUe=(GtkTable*)gtk_builder_get_object(p_builder,"tab_ue_enseignee");
    gtk_table_resize(tableUe,tabUe->nbUe+1,5);

    GtkWidget *col1=gtk_label_new("Séquence");
    GtkWidget *col2=gtk_label_new("Code UE");
    GtkWidget *col3=gtk_label_new("Intitulé");
    GtkWidget *col4=gtk_label_new("Abilité");
    GtkWidget *col5=gtk_label_new("Responsable de l'UE");

    gtk_table_attach_defaults(tableUe,col1,0,1,0,1);
    gtk_table_attach_defaults(tableUe,col2,1,2,0,1);
    gtk_table_attach_defaults(tableUe,col3,2,3,0,1);
    gtk_table_attach_defaults(tableUe,col4,3,4,0,1);
    gtk_table_attach_defaults(tableUe,col5,4,5,0,1);

    if(tabUe->nbUe>0    &&  tabUe!=NULL &&  tabEnseigne!=NULL   )
    {
        int i=0;
        while(i<tabUe->nbUe)
        {
            /*   affectationAutomatiqueEtudiantGroupe(tabUe->tabUe[i],4);*/
            int j=0;
            while(tabUe->tabUe[i]->codeUE!=tabEnseigne->tabEnseigne[j]->codeUe  &&  j<tabEnseigne->nbEnseigne)
            {
                j++;
            }
            char*   c_seq=calloc(1,sizeof(char));
            sprintf(c_seq,"%d",tabUe->tabUe[i]->sequence);
            GtkWidget *sequence_label=gtk_label_new(c_seq);

            char*   c_code_ue=calloc(5,sizeof(char));
            sprintf(c_code_ue,"%d",tabUe->tabUe[i]->codeUE);
            GtkWidget *code_ue_label=gtk_label_new((gchar*)c_code_ue);

            GtkWidget *intitule_label=gtk_label_new((gchar*)tabUe->tabUe[i]->intitule);

            char*   c_categorie=calloc(10,sizeof(char));


            if(tabEnseigne->tabEnseigne[j]->ensCm==1)
            {
                strcat(c_categorie,"CM");
                strcat(c_categorie," ");
            }

            if(tabEnseigne->tabEnseigne[j]->ensTd==1)
            {
                strcat(c_categorie,"TD");
            strcat(c_categorie," ");
            }

            if(tabEnseigne->tabEnseigne[j]->ensTp==1)
            {
                strcat(c_categorie,"TP");
            }

            GtkWidget *categorie_label=gtk_label_new((gchar*)c_categorie);

            char*   respue=calloc(30,sizeof(char));
            Ens*ens=recResponsableUe(tabUe->tabUe[i]);
            if(ens!=NULL)
            {
                strcat(respue,ens->nomEns);
                strcat(respue," ");
                strcat(respue,ens->prenomEns);
                detEns(&ens);
            }
            else
            {
                strcat(respue,"Auncun responsable");
            }

            GtkWidget *resp_ue_label=gtk_label_new((gchar*)respue);

            gtk_table_attach_defaults(tableUe,sequence_label,0,1,i+1,i+2);
            gtk_table_attach_defaults(tableUe,code_ue_label,1,2,i+1,i+2);
            gtk_table_attach_defaults(tableUe,intitule_label,2,3,i+1,i+2);
            gtk_table_attach_defaults(tableUe,categorie_label,3,4,i+1,i+2);

            gtk_table_attach_defaults(tableUe,resp_ue_label,4,5,i+1,i+2);

            i++;
        }
    }
    else
    {
        gtk_table_attach_defaults(tableUe,gtk_label_new("Vous n'enseigné aucune UE"),0,5,1,2);
    }

    GtkTextView *texteView=(GtkTextView*)gtk_builder_get_object(p_builder,"enseignement_text_view_ens");

    char   *tabtext;
    if(tabEnseignement!=NULL)
    {
        tabtext=calloc(50*tabEnseignement->nbEnseignement,sizeof(char));

        if(tabEnseignement->nbEnseignement>0)
        {
            int cpt=0;
            while(cpt<tabEnseignement->nbEnseignement)
            {
                if(estUneDateDeLaSemaine(tabEnseignement->tabEnseignement[cpt]->date)==0)
                {
                    strcat(tabtext,"\n");
                    strcat(tabtext,getEnseignementText(tabEnseignement->tabEnseignement[cpt]," "));
                }
                cpt++;
            }
        }
        else
        {
            tabtext="Vous n'avez aucun cours de prévu";
        }

    }
    else
    {
        tabtext="Vous n'avez aucun cours de prévu";
    }

    strcat(tabtext,"\0");

    GtkTextBuffer*buf=gtk_text_buffer_new(NULL);

    gtk_text_buffer_set_text(buf,tabtext,-1);
    gtk_text_view_set_buffer(texteView,buf);

    GtkTable *tableTomuss=(GtkTable*)gtk_builder_get_object(p_builder,"tomuss_table_ens");
    gtk_table_resize(tableUe,tabUe->nbUe+1,1);
    gtk_table_set_homogeneous(tableTomuss,FALSE);

    initEnsTableTomuuss(ens,tableTomuss,tabUe);
    TabEtu  *   listEtu=recListEtuParEns(ens);
    char    *   c_nbetu=calloc(3,sizeof(char));
    sprintf(c_nbetu,"%d",listEtu->nbEtu);
    char    *   c_nbEtuLabel=calloc(50,sizeof(char));
    strcat(c_nbEtuLabel,"Vous êtes responsable de ");
    strcat(c_nbEtuLabel,c_nbetu);
    strcat(c_nbEtuLabel," étudiants");
    gtk_label_set_text (
          GTK_LABEL (gtk_builder_get_object (p_builder, "label_resp_nb_etu")),(gchar*)(c_nbEtuLabel));

    TabUe   *   tabUeResp=recUeParEnseignantResp(ens);
    char    *   c_nbue=calloc(3,sizeof(char));
    sprintf(c_nbue,"%d",tabUeResp->nbUe);
    char    *   c_nbUeLabel=calloc(50,sizeof(char));
    strcat(c_nbUeLabel,"Vous êtes responsable de ");
    strcat(c_nbUeLabel,c_nbue);
    strcat(c_nbUeLabel," ue(s)");
    gtk_label_set_text (
          GTK_LABEL (gtk_builder_get_object (p_builder, "label_resp_nb_ue")),(gchar*)(c_nbUeLabel));

    detTab((void**)&listEtu);
    detTab(((void**)&tabUeResp));
    detTab(((void**)&tabUe));
    detTab(((void**)&tabEnseignement));
    detTab(((void**)&tabEnseigne));

}

void    preparerFenetreGererUe(UE*ue)
{

    TabEtu  *   tabEtu=recEtuInscritParUe(ue);
    TabIP   *   tabIp=rchIPParUe(ue);
    TabEnseignant*  tabEnseignant=recEnseignantParUe(ue);
    TabEnseignement* tabEnseignement=recEnseignementParUe(ue);
    Ens *   ens=recResponsableUe(ue);

    TabCC   *tabCC=recCCParUe(ue);

    char* c_ens=calloc(30,sizeof(char));
    strcat(c_ens,ens->nomEns);
    strcat(c_ens,"  ");
    strcat(c_ens,ens->prenomEns);

    char*  c_nbEtu=calloc(3,sizeof(char));
    sprintf(c_nbEtu,"%d",tabEtu->nbEtu);
    char* c_label_nbEtu=calloc(30,sizeof(char));
    strcat(c_label_nbEtu,c_nbEtu);
    strcat(c_label_nbEtu,"  étudiants inscrits");

    char*c_code_ue=calloc(10,sizeof(char));
    sprintf(c_code_ue,"%d",ue->codeUE);
    gtk_label_set_text (
        GTK_LABEL (label_respUE_GestionUE),(gchar*)(c_ens));
    gtk_label_set_text (
        GTK_LABEL (label_nbEtu_GestionUE),(gchar*)(c_label_nbEtu));
    gtk_label_set_text (
        GTK_LABEL (label_codeUE_GestionUE),(gchar*)(c_code_ue));

    char*   textlabnbr=calloc(15,sizeof(char));
    char*   c_nbgr=calloc(2,sizeof(char));
    sprintf(c_nbgr,"%d",getNbGroupeUe(ue));
    strcat(textlabnbr,c_nbgr);
    strcat(textlabnbr," groupes");
    gtk_label_set_text (
        GTK_LABEL (label_nbGroupe_GestionUE),(gchar*)(textlabnbr));

    free(c_nbEtu);
    free(c_label_nbEtu);


    detTab((void**)&tabEtu);
    detTab((void**)&tabIp);
    detTab((void**)&tabEnseignant);
    detTab((void**)&tabEnseignement);
    detTab((void**)&tabCC);
}

void    preparerFenetreScolarite()
{

}

void    initEnsTableTomuuss(Ens*ens,GtkTable*tableTomuss,TabUe*tabUe)
{
    gtk_table_resize(tableTomuss,tabUe->nbUe+1,1);
    int i=0;
    while(i<tabUe->nbUe)
    {
        GtkWidget*   box=recHBoxPourUeEns(ens,tabUe->tabUe[i]);
        gtk_table_attach_defaults(tableTomuss,box,0,1,i,i+1);
        i++;
    }
}

void    initEtuTableTomuuss(Etu*etu,GtkTable*tableTomuss,TabUe*tabUe)
{

    gtk_table_resize(tableTomuss,tabUe->nbUe+1,1);
    int i=0;
    while(i<tabUe->nbUe)
    {
        gtk_table_attach_defaults(tableTomuss,recHBoxPourUeEtu(etu,tabUe->tabUe[i]),0,1,i,i+1);
        i++;
    }
}



GtkWidget*    recHBoxPourUeEns(Ens*ens,UE*ue)
{
    GtkWidget   *hBox=gtk_hbox_new(FALSE,10);
    TabEnseignement *   tabEnseignement=recEnseignementParEnseignant(ens);
    int    test=0;
    int i=0;
    char*uetext=calloc(20,sizeof(char));
    strcat(uetext,ue->intitule);

    GtkWidget *labelue=gtk_label_new(uetext);

    gtk_box_pack_start(GTK_BOX(hBox), labelue ,FALSE, FALSE, 10);

    if(tabEnseignement!=NULL)
    {
        while(i<tabEnseignement->nbEnseignement)
        {

            if(tabEnseignement->tabEnseignement[i]->codeUE==ue->codeUE)
            {
                char*text=calloc(100,sizeof(char));

                test=1;
                strcat(text,getEnseignementText(tabEnseignement->tabEnseignement[i],"\n"));

                GtkWidget *label=gtk_button_new();
                gtk_button_set_label((GtkButton*)label,(gchar*)text);
                char*   c_id=calloc(10,sizeof(char));
                sprintf(c_id,"%d",tabEnseignement->tabEnseignement[i]->numEnseignement);
                gtk_widget_set_name(label,c_id);

                g_signal_connect(label, "clicked",
                             G_CALLBACK   (cb_enseignement_click),c_id);
                GtkWidget   *sep=gtk_vseparator_new();
                gtk_box_pack_start(GTK_BOX(hBox),GTK_WIDGET(label) ,FALSE, FALSE, 10);
                gtk_box_pack_start(GTK_BOX(hBox),GTK_WIDGET(sep) ,FALSE, FALSE, 10);
            }
            i++;
        }
        if(test==0)
        {
            GtkWidget *label=gtk_label_new("Aucun enseignement de  prévu");
            gtk_box_pack_start(GTK_BOX(hBox), label ,FALSE, FALSE, 10);
        }
    }
    else
    {
        GtkWidget *label=gtk_label_new("Aucun enseignement de  prévu");
        gtk_box_pack_start(GTK_BOX(hBox), label ,FALSE, FALSE, 10);
    }
    detTab((void**)&tabEnseignement);
   /*TabControle*    tabCC=recControleParEtu(etu);*/
    return  hBox;
}


void    cb_enseignement_click(GtkWidget *widg, GdkEvent *event, gpointer message)
{
    char*id=(char*)gtk_widget_get_name(widg);
    int  numEnseignement=atoi(id);
    Enseignement*enseignement=recEnseignementParCode(numEnseignement);

    preparerFenetrePresence(enseignement);
     connectSignal_FenetrePresence();

    afficheFenetre(GTK_WINDOW(windowFenPresence));

    detEnseignement(&enseignement);
    printf("%s\n",id);
}


GtkWidget*    recHBoxPourUeEtu(Etu*etu,UE*ue)
{
    GtkWidget   *hBox=gtk_hbox_new(FALSE,10);
    TabEnseignement *   tabEnseignement=recEnseignementParEtu(etu);
    int    test=0;
    int i=0;

    char*uetext=calloc(20,sizeof(char));
    strcat(uetext,ue->intitule);

    GtkWidget *labelue=gtk_label_new(uetext);
    gtk_box_pack_start(GTK_BOX(hBox), labelue ,FALSE, FALSE, 10);

    if(tabEnseignement!=NULL)
    {
        while(i<tabEnseignement->nbEnseignement)
        {
            if(tabEnseignement->tabEnseignement[i]->codeUE==ue->codeUE)
            {
                 char*text=calloc(100,sizeof(char));
                test=1;
                strcat(text,getEnseignementText(tabEnseignement->tabEnseignement[i],"\n"));

                strcat(text,"Presence:    ");
                char*pres=recPresenceEtuAEnseignement(etu,tabEnseignement->tabEnseignement[i]);

                if(pres!=NULL)
                {
                    strcat(text,pres);
                }
                else
                {
                    strcat(text,"???");
                }

                GtkWidget *label=gtk_label_new(text);
                gtk_box_pack_start(GTK_BOX(hBox),GTK_WIDGET(label) ,FALSE, FALSE, 10);
            }
            i++;
        }
        if(test==0)
        {
            GtkWidget *label=gtk_label_new("Aucun enseignement de  prévu");
            gtk_box_pack_start(GTK_BOX(hBox), label ,FALSE, FALSE , 10);
        }
    }
    else
    {
         GtkWidget *label=gtk_label_new("Aucun enseignement de  prévu");
        gtk_box_pack_start(GTK_BOX(hBox), label ,FALSE, FALSE, 10);
    }

   /* TabControle*    tabCC=recControleParEtu(etu);*/
    return  hBox;

}

void setImageProfil(int id,char * idImage)
{
    GtkImage *image=(GtkImage*)gtk_builder_get_object(p_builder,idImage);

    char addimage[100];
    sprintf(addimage, "data/%d.jpg",id);
    gtk_image_set_from_file(image,addimage);
    /*gtk_image_set_from_file(image,"data/photo.jpg");*/
}




/** @brief lancerApplicationScolarite
  *
  * @todo: document this function
  */
void lancerApplicationScolarite()
{

}

/** @brief lancerApplicationAdministrateur
  *
  * @todo: document this function
  */
void lancerApplicationAdministrateur()
{
  initFenAdmin();
    connectSignal_FenAdmin();
gtk_widget_show_all(FenAdmin);
    /*char addimage[100];
    sprintf(addimage, "data/%d.jpg",etudiant->numEtu);
*/
/*
    gtk_window_fullscreen(GTK_WINDOW(FenEtudiant));
    gtk_window_set_resizable(GTK_WINDOW(FenEtudiant),TRUE);
    afficheFenetreEtudiant();
*/
}

/** @brief lancerApplicationEnseignant
  *
  * @todo: document this function
  */
void lancerApplicationEnseignant(Ens*enseignant)
{
    preparerFenetreEnseignant(enseignant);
    setImageProfil(enseignant->numEns,"image_ens");
    gtk_window_set_default_size(listFenetres->fenetreEnseignant,1000,700);
    gtk_window_set_resizable(listFenetres->fenetreEnseignant,TRUE);
    afficheFenetre(listFenetres->fenetreEnseignant);

    return ;
}

/*Signaux   nécessaire  à   la  fenetre authentification:
    -cb_quit_identification:ferme   les  fenetres et  quitte  l'application,
        callback utiliser par  differentes fenetres
    -cb_valider_identification:recupere le login et le mot de passe de l'utilisateur et lance l'interface, message d'erreur sinon*/

void cb_quit_application()
{
    cb_quit_identification();
    gtk_main_quit();
}

void    cb_valider_identificaion()
{
    char*p_id=calloc(20,sizeof(char));
    p_id=(char*)gtk_entry_get_text(entry_Identifiant);

    char*p_mdp=calloc(20,sizeof(char));
    p_mdp=(char*)gtk_entry_get_text(entry_mdp_Identifiant);



    Login * log=rchLogParIdMdp(p_id,p_mdp);
    if(log!=NULL)
    {
        gtk_widget_hide_all(FenIdentification);
        lancerApplication(log);
    }
    else
    {
        GtkWidget *dialog;
        dialog = gtk_message_dialog_new_with_markup (  GTK_WINDOW(FenIdentification),
                 GTK_DIALOG_DESTROY_WITH_PARENT,
                 GTK_MESSAGE_ERROR,
                 GTK_BUTTONS_CLOSE,
                 "Login  Inconnu, veuillez réessayer");
        gtk_dialog_run (GTK_DIALOG (dialog));
        gtk_widget_destroy (dialog);

    }
}

/************************************************************************************************************************/

void    cb_ajout_etudiant()
{

}

void    cb_ajout_enseignant()
{

}

void    cb_creer_enseignement()
{

}

void   cb_modifier_etudiant()
{

}

void    cb_modifier_enseignant()
{

}

void    cb_modifier_enseignement()
{

}


void    cb_creer_groupe_pour_ue()
{

}

void    cb_noter_eleve()
{

}

void    cb_presence_eleve()
{

}




void        connectSignal_FenetreEnseignant()
{
    g_signal_connect(gtk_builder_get_object(p_builder,"bouton_gerer_ue"), "clicked",
                     G_CALLBACK   (cb_enseignant_gerer_ue_bouton_click),NULL);

    g_signal_connect(gtk_builder_get_object(p_builder,"bouton_gerer_ip"), "clicked",
                     G_CALLBACK   (cb_enseignant_gerer_ip_bouton_click),NULL);

    g_signal_connect(listFenetres->fenetreEnseignant,"delete-event", G_CALLBACK   (cb_quit_application_enseignant),NULL);

    g_signal_connect(gtk_builder_get_object(p_builder,"button_dec_ens"), "clicked",
                     G_CALLBACK   (cb_quit_application_enseignant),NULL);

}


void    connectSignal_FenetrePresence()
{
    g_signal_connect(bouton_valider_presence,"clicked",G_CALLBACK(cb_valid_presence),NULL);
}

void        connectSignal_FenetreIp()
{

}

void    hide_window(GtkWidget *  widg)
{
    gtk_widget_hide(widg);
}
void hide_fenetre_list_ue()
{
    gtk_widget_hide_all(GTK_WIDGET(listFenetres->fenetreListUeEns));
}
void    cb_enseignant_gerer_ip_bouton_click()
{
    GtkLabel    * labelNumEns=(GtkLabel*)gtk_builder_get_object(p_builder,"label_identifiant_enseignant");
    int numEns=atoi(gtk_label_get_text(labelNumEns));
    Ens *ens=recEnsParCode(numEns);
     /*gtk_window_set_default_size(listFenetres->fenetreIp,800,650);*/
    preparerFenetreIp(ens);
    afficheFenetre(GTK_WINDOW(windowFenIp));
}

void    cb_enseignant_gerer_ue_bouton_click()
{
    GtkLabel    * labelNumEns=(GtkLabel*)gtk_builder_get_object(p_builder,"label_identifiant_enseignant");
    int numEns=atoi(gtk_label_get_text(labelNumEns));
    Ens *ens=recEnsParCode(numEns);
    TabUe   *tabUe=recUeParEnseignantResp(ens);
    GtkTable*   tableUe=(GtkTable*)gtk_builder_get_object(p_builder,"table_list_ue_bouton");
    if(tabUe->nbUe>0)
    {
        gtk_table_resize(tableUe,tabUe->nbUe,1);
    }
    else
    {
        gtk_table_resize(tableUe,1,1);
        GtkWidget *label=gtk_label_new("Vous n'ètes responsable d'aucune UE");
        gtk_table_attach_defaults(tableUe,label,0,1,0,1);
    }

    int i=0;
    while(i<tabUe->nbUe)
    {
        GtkWidget   *   bouton=gtk_button_new();
        char*   c_codeUe=calloc(5,sizeof(char));
        sprintf(c_codeUe,"%d",tabUe->tabUe[i]->codeUE);
        gtk_button_set_label(GTK_BUTTON(bouton),tabUe->tabUe[i]->intitule);
        gtk_widget_set_name(bouton,c_codeUe);
        g_signal_connect(bouton, "clicked",
                         G_CALLBACK   (cb_gerer_ue),
                        c_codeUe);
        gtk_table_attach_defaults(tableUe,bouton,0,1,i,i+1);
        i++;
    }

    detTab((void**)&tabUe);
    afficheFenetre(listFenetres->fenetreListUeEns);
}

void    cb_gerer_ue(GtkWidget *widg, GdkEvent *event, gpointer message)
{
    char*c_codeUe=(char*)gtk_widget_get_name(widg);
    int codeUe=atoi(c_codeUe);
    UE*ue=recUEParCode(codeUe);
    initFenGestionUE();
    preparerFenetreGererUe(ue);
     connectSignal_FenetreGererUe();
     initFenDefGroupe();
    detUE(&ue);
   gtk_widget_show_all(FenGestionUE);
}
/*************************************************************************************************************************/

void cb_valid_presence(GtkWidget *widg, GdkEvent *event, gpointer message)
{
gtk_container_foreach(GTK_CONTAINER(table_etu_Presence),(GtkCallback)(cb_for_etu_pre_valid),NULL);
gtk_widget_destroy(windowFenPresence);
}

void  cb_for_etu_pre_valid(GtkWidget *widg, GdkEvent *event, gpointer message)
{
   GtkBox *box=(GtkBox*)widg;
   GList*list=gtk_container_get_children(GTK_CONTAINER(box));
    GtkCheckButton*but1=g_list_nth_data(list,3);
    GtkCheckButton*but2=g_list_nth_data(list,4);
    GtkCheckButton*but3=g_list_nth_data(list,5);
char*text=(char*)gtk_widget_get_name(GTK_WIDGET(box));
char*pres=calloc(10,sizeof(char));
if( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(but1) ))
   {
    pres="PRESENT";
   }
   else if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(but2) ))
           {
               pres="ABINJ";
           }else if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(but3)))
                    {
                        pres="ABJUS";
                    }
                    else
                    {
                        pres=NULL;
                    }
 char**tab=g_strsplit((gchar*)text,(gchar*)":",100);
 int numEtu=atoi(tab[0]);
 int numEns=atoi(tab[1]);
 Enseignement*ens=recEnseignementParCode(numEns);

 Etu*etu=recEtuParCode(numEtu);
if(pres!=NULL)
{

setPresenceEtuAEnseignement(etu,ens,pres);
}
pres=NULL;
}

/*Fonction connectant les signaux aux callback de la fenetre d'identification                                            */
void    connectSignal_FenetreIdentification()
    {
    g_signal_connect(bouton_valider_Identifiant, "clicked",
                     G_CALLBACK   (cb_valider_identificaion),
                     NULL);

    g_signal_connect (FenIdentification,
                      "delete-event",
                      G_CALLBACK (cb_quit_application),
                      NULL);
    }

/***************************************************************************************************************************/


/*Fonction connectant les signaux aux callback de la fenetre d'etudiant                                                     */
void    connectSignal_FenetreEtudiant()
{
    g_signal_connect(bouton_deconnection_Etudiant, "clicked",
                     G_CALLBACK   (cb_quit_application_etudiant),
                     NULL);

    g_signal_connect (FenEtudiant,
                      "delete-event",
                      G_CALLBACK (cb_quit_application_etudiant),
                      NULL);
}

/****************************************************************************************************************************/


/*Fonction connectant les signaux aux callback de la fenetre d'unité d'enseignement                                         */
void    connectSignal_FenetreGererUe()
{
    g_signal_connect(FenGestionUE,"delete-event", G_CALLBACK   (cb_quit_fenGestionUE),
                NULL);
     g_signal_connect(bouton_fermer_GestionUE,"clicked", G_CALLBACK   (cb_quit_fenGestionUE),
                NULL);
    g_signal_connect(bouton_defgroupe_GestionUE,"clicked", G_CALLBACK   (set_dialog_def_groupe),
                NULL);
}

void    set_dialog_def_groupe()
{


    gtk_window_set_default_size(GTK_WINDOW(FenDefGroupe),250,250);
    gtk_widget_show_all(FenDefGroupe);
}

void    connectSignal_FenetreListUeEns()
{
    g_signal_connect(listFenetres->fenetreListUeEns,"delete-event", G_CALLBACK   (hide_fenetre_list_ue),
                    NULL);
    g_signal_connect(gtk_builder_get_object(p_builder,"bouton_fermer_list_ue"),"clicked",G_CALLBACK(hide_fenetre_list_ue),NULL);
}

/****************************************************************************************************************************/

/*Fonction connectant les signaux aux callback de la fenetre d'ajout d'une unité d'enseignement                             */
void    connectSignal_FenetreAjoutUe()
{

}

/****************************************************************************************************************************/

/*Fonction principal de connexion des signaux aux callback de toutes les fenetres de l'application                          */
void    connectSignal()
{
    connectSignal_FenetreIdentification();
}




void    initFenIp()
{
    windowFenIp=(GtkWidget*)gtk_window_new(GTK_WINDOW_TOPLEVEL);

    tablePrincipal=(GtkWidget*)gtk_table_new(10,1,FALSE);
    table_etu=(GtkWidget*)gtk_table_new(1,1,TRUE);
    table_ue=(GtkWidget*)gtk_table_new(1,1,TRUE);
    table_ue_etu=(GtkWidget*)gtk_table_new(1,1,TRUE);
    table_bouton_fen_ip=(GtkWidget*)gtk_table_new(1,3,TRUE);


    sep1=(GtkHSeparator*)gtk_hseparator_new();
    sep2=(GtkHSeparator*)gtk_hseparator_new();
    sep3=(GtkHSeparator*)gtk_hseparator_new();

    label1=(GtkLabel*)gtk_label_new("Etudiants");
    label2=(GtkLabel*)gtk_label_new("Ip de l'étudiants");
    label3=(GtkLabel*)gtk_label_new("UEs");

    inscrireBouton=(GtkButton*)gtk_button_new_with_label("Inscrire");
    desinscrireBouton=(GtkButton*)gtk_button_new_with_label("Desinscrire");

    scrollWinTableEtu=(GtkWidget*)gtk_scrolled_window_new(NULL,NULL);
    scrollTableUe=(GtkWidget*)gtk_scrolled_window_new(NULL,NULL);

    gtk_window_set_modal(GTK_WINDOW(windowFenIp),TRUE);

    gtk_container_add(GTK_CONTAINER(windowFenIp),tablePrincipal);

    gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrollWinTableEtu),table_etu);
    gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrollTableUe),table_ue);

    gtk_scrolled_window_set_placement(GTK_SCROLLED_WINDOW(scrollWinTableEtu),TRUE);
    gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrollWinTableEtu),GTK_SHADOW_IN);

    gtk_scrolled_window_set_placement(GTK_SCROLLED_WINDOW(scrollTableUe),TRUE);
    gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrollTableUe),GTK_SHADOW_IN);


    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal),GTK_WIDGET(label1),0,1,0,1);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal),scrollWinTableEtu,0,1,1,2);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal),GTK_WIDGET(sep1),0,1,2,3);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal),GTK_WIDGET(label2),0,1,3,4);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal),table_ue_etu,0,1,4,5);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal),GTK_WIDGET(sep2),0,1,5,6);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal),GTK_WIDGET(label3),0,1,6,7);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal),scrollTableUe,0,1,7,8);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal),GTK_WIDGET(sep3),0,1,8,9);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal),table_bouton_fen_ip,0,1,9,10);


    gtk_table_attach_defaults(GTK_TABLE(table_bouton_fen_ip),GTK_WIDGET(inscrireBouton),0,1,0,1);
    gtk_table_attach_defaults(GTK_TABLE(table_bouton_fen_ip),GTK_WIDGET(desinscrireBouton),2,3,0,1);

    gtk_window_set_default_size(GTK_WINDOW(windowFenIp),800,700);

    g_signal_connect(inscrireBouton,"clicked",G_CALLBACK(cb_inscrire_etu),NULL);
    g_signal_connect(desinscrireBouton,"clicked",G_CALLBACK(cb_desinscrire_etu),NULL);

    numEtuSel=0;

}

GtkHBox * recBoxPresenceEtu(Etu*etu, Enseignement*enseignement)
{
    GtkHBox   *hBox=(GtkHBox*)gtk_hbox_new(TRUE,6);
    char*presence=recPresenceEtuAEnseignement(etu,enseignement);
    char*c_numEtu=(char*)calloc(20,sizeof(char));
    sprintf(c_numEtu,"%d",etu->numEtu);

    GtkLabel * labelNumEtu=(GtkLabel*)gtk_label_new((gchar*)c_numEtu);
    GtkLabel * labelNomEtu=(GtkLabel*)gtk_label_new((gchar*)etu->nomEtu);
    GtkLabel * labelPrenomEtu=(GtkLabel*)gtk_label_new((gchar*)etu->prenomEtu);


    GtkCheckButton* cbut1=(GtkCheckButton*)gtk_check_button_new_with_label("PRESENT");
    GtkCheckButton* cbut2=(GtkCheckButton*)gtk_check_button_new_with_label("ABINJ");
    GtkCheckButton* cbut3=(GtkCheckButton*)gtk_check_button_new_with_label("ABJUS");


/*
         char*name=calloc(30,sizeof(char));
        strcat(name,c_numEtu);
        strcat(name,":");
        strcat(name,"cbut1");

    gtk_widget_set_name(GTK_WIDGET(cbut1),name);
        char*name=calloc(30,sizeof(char));
        strcat(name,c_numEtu);
        strcat(name,":");
        strcat(name,"cbut2");

    gtk_widget_set_name(GTK_WIDGET(cbut2),name);
        char*name=calloc(30,sizeof(char));
        strcat(name,c_numEtu);
        strcat(name,":");
        strcat(name,"cbut3");

    gtk_widget_set_name(GTK_WIDGET(cbut3),name);
*/
    gtk_box_pack_start(GTK_BOX(hBox), GTK_WIDGET(labelNumEtu)    ,FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hBox), GTK_WIDGET(labelNomEtu)    ,FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hBox), GTK_WIDGET(labelPrenomEtu) ,FALSE, FALSE, 10);

    gtk_box_pack_start(GTK_BOX(hBox), GTK_WIDGET(cbut1) ,FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hBox), GTK_WIDGET(cbut2) ,FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hBox), GTK_WIDGET(cbut3) ,FALSE, FALSE, 10);
    if(presence!=NULL)
    {
        if(strcmp(presence,"PRESENT")==0)
        {
            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbut1),1);
        }
        else if(strcmp(presence,"ABINJ")==0)
        {
            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbut2),1);
        }
        else if(strcmp(presence,"ABJUS")==0)
        {
            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbut3),1);
        }
    }

    return  hBox;
}


void initFenPresence(Enseignement*enseignement)
{
    windowFenPresence=(GtkWidget*)gtk_window_new(GTK_WINDOW_TOPLEVEL);

    tablePrincipal_presence=(GtkWidget*)gtk_table_new(5,1,FALSE);
    TabEtu*  tabEtu=recEtuParEnseignement(enseignement);
    table_etu_Presence=(GtkWidget*)gtk_table_new(tabEtu->nbEtu,1,TRUE);
    int i=0;
    while(i<tabEtu->nbEtu)
    {
        GtkHBox  *box=recBoxPresenceEtu(tabEtu->tabEtu[i],enseignement);
        char*name=calloc(41,sizeof(char));
        char*c_numEtu=calloc(20,sizeof(char));
        char*c_numEns=calloc(20,sizeof(char));
        sprintf(c_numEtu,"%d",tabEtu->tabEtu[i]->numEtu);
        sprintf(c_numEns,"%d",enseignement->numEnseignement);
        strcat(name,c_numEtu);
        strcat(name,":");
        strcat(name,c_numEns);

        gtk_widget_set_name(GTK_WIDGET(box),(gchar*)name);
        gtk_table_attach_defaults(GTK_TABLE(table_etu_Presence),GTK_WIDGET(box),0,1,i,i+1);
        i++;
    }

    sep1_Presence=(GtkHSeparator*)gtk_hseparator_new();
    sep2_Presence=(GtkHSeparator*)gtk_hseparator_new();

    label_enseignement_presence=(GtkLabel*)gtk_label_new("Enseignement");

    bouton_valider_presence=(GtkButton*)gtk_button_new_with_label("Valider");

    scrollWinTableEtuPrecence=(GtkWidget*)gtk_scrolled_window_new(NULL,NULL);

    gtk_window_set_modal(GTK_WINDOW(windowFenPresence),TRUE);
    gtk_container_add(GTK_CONTAINER(windowFenPresence),tablePrincipal_presence);



    gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrollWinTableEtuPrecence),table_etu_Presence);


    gtk_scrolled_window_set_placement(GTK_SCROLLED_WINDOW(scrollWinTableEtuPrecence),TRUE);
    gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrollWinTableEtuPrecence),GTK_SHADOW_IN);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_presence),GTK_WIDGET(label_enseignement_presence),0,1,0,1);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_presence),GTK_WIDGET(sep1_Presence),0,1,1,2);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_presence),scrollWinTableEtuPrecence,0,1,2,3);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_presence),GTK_WIDGET(sep2_Presence),0,1,3,4);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_presence),GTK_WIDGET(bouton_valider_presence),0,1,4,5);

    gtk_window_set_default_size(GTK_WINDOW(windowFenPresence),800,700);
}


void  preparerFenetrePresence(Enseignement*ens)
{
    initFenPresence(ens);
}


void    cb_desinscrire_etu()
{
    gtk_container_foreach(GTK_CONTAINER(table_ue),(GtkCallback)cb_desinscrire_etu_par_ue,NULL);

    GtkWidget   *   widg=gtk_button_new();
    char*c_num=calloc(20,sizeof(char));
    sprintf(c_num,"%d",numEtuSel);
    gtk_widget_set_name(widg,c_num);
    cb_init_tabUeEtu(widg,NULL,NULL);
    gtk_widget_destroy(widg);
    free(c_num);
}



void cb_inscrire_etu()
{
    gtk_container_foreach(GTK_CONTAINER(table_ue),(GtkCallback)cb_inscrire_etu_par_ue,NULL);

    GtkWidget   *   widg=gtk_button_new();
    char*c_num=calloc(20,sizeof(char));
    sprintf(c_num,"%d",numEtuSel);
    gtk_widget_set_name(widg,c_num);
    cb_init_tabUeEtu(widg,NULL,NULL);
    gtk_widget_destroy(widg);
    free(c_num);
}

/****************************************************************************************************************************/
void    cb_inscrire_etu_par_ue(GtkWidget*widg)
{
    if(gtk_toggle_button_get_active ((GtkToggleButton*)widg))
    {
       char*   c_codeUe=(char*)gtk_widget_get_name(widg);
        int codeUe=atoi(c_codeUe);
        UE*ue=recUEParCode(codeUe);
        Etu*etu=recEtuParCode(numEtuSel);
        inscrireEtudiantUe(etu,ue,2012,'2');
        gtk_toggle_button_set_active((GtkToggleButton*)widg,0);
    }
}



void    cb_desinscrire_etu_par_ue(GtkWidget*widg)
{
    if(gtk_toggle_button_get_active ((GtkToggleButton*)widg))
    {
       char*   c_codeUe=(char*)gtk_widget_get_name(widg);
        int codeUe=atoi(c_codeUe);
        UE*ue=recUEParCode(codeUe);
        Etu*etu=recEtuParCode(numEtuSel);
        desinscrireEtudiantUe(etu,ue);
        gtk_toggle_button_set_active((GtkToggleButton*)widg,0);
    }
}

void initFenDefGroupe()
{
    FenDefGroupe=(GtkWidget*)gtk_window_new(GTK_WINDOW_TOPLEVEL);

    tablePrincipal_DefGroupe=(GtkWidget*)gtk_table_new(7,1,FALSE);


    sep1_DefGroupe=(GtkHSeparator*)gtk_hseparator_new();
    sep2_DefGroupe=(GtkHSeparator*)gtk_hseparator_new();
    sep3_DefGroupe=(GtkHSeparator*)gtk_hseparator_new();

    hbox1_DefGroupe=(GtkHBox*)gtk_hbox_new(TRUE,3);
    hbox2_DefGroupe=(GtkHBox*)gtk_hbox_new(TRUE,3);

    label_NumUE_DefGroupe=(GtkLabel*)gtk_label_new("NomUE");
    label_nb_DefGroupe=(GtkLabel*)gtk_label_new("Choisir un groupe");

    combboxDefGroupe=(GtkComboBox*)gtk_combo_box_new_text();
    gtk_combo_box_append_text(combboxDefGroupe,"1");
    gtk_combo_box_append_text(combboxDefGroupe,"2");
    gtk_combo_box_append_text(combboxDefGroupe,"3");
    gtk_combo_box_append_text(combboxDefGroupe,"4");
    gtk_combo_box_append_text(combboxDefGroupe,"5");
    bouton_valider_DefGroupe=(GtkButton*)gtk_button_new_with_label("Valider");
    g_signal_connect(bouton_valider_DefGroupe,"clicked",G_CALLBACK(cb_def_auto_gr),NULL);

    gtk_window_set_modal(GTK_WINDOW(FenDefGroupe),TRUE);
    gtk_container_add(GTK_CONTAINER(FenDefGroupe),tablePrincipal_DefGroupe);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_DefGroupe),GTK_WIDGET(label_NumUE_DefGroupe),0,1,0,1);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_DefGroupe),GTK_WIDGET(sep1_DefGroupe),0,1,1,2);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_DefGroupe),GTK_WIDGET(label_nb_DefGroupe),0,1,2,3);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_DefGroupe),GTK_WIDGET(sep2_DefGroupe),0,1,3,4);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_DefGroupe),GTK_WIDGET(hbox1_DefGroupe),0,1,4,5);
    gtk_box_pack_start(GTK_BOX(hbox1_DefGroupe), GTK_WIDGET(combboxDefGroupe), TRUE, TRUE, 10);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_DefGroupe),GTK_WIDGET(sep3_DefGroupe),0,1,5,6);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_DefGroupe),GTK_WIDGET(hbox2_DefGroupe),0,1,6,7);
    gtk_box_pack_start(GTK_BOX(hbox2_DefGroupe), GTK_WIDGET(bouton_valider_DefGroupe), TRUE, TRUE, 10);


    gtk_window_set_default_size(GTK_WINDOW(FenDefGroupe),800,700);

}



void  preparerFenetreDefGroupe()
{
    initFenDefGroupe();
}



void cb_def_auto_gr()
{

    char*c_codeue=(char*)gtk_label_get_text(GTK_LABEL(label_codeUE_GestionUE));
    int codeUe=atoi(c_codeue);
    UE *ue=recUEParCode(codeUe);
    char*c_nbgr=(char*)gtk_combo_box_get_active_text(combboxDefGroupe);
    if(c_nbgr!=NULL)
    {


    int nbgr=atoi(c_nbgr);
    definitAutomatiquementGroupe(ue,nbgr);
    free(c_nbgr);
    free(c_codeue);


    preparerFenetreGererUe(ue);
   gtk_widget_hide_all(FenDefGroupe);
    }
    detUE(&ue);

}


void initFenIdentification()
{
    FenIdentification=NULL;
    hbox4_Identifiant=NULL;
    hbox3_Identifiant=NULL;
    hbox1_Identifiant=NULL;
    hbox2_Identifiant=NULL;

    label_mdp_Identifiant=NULL;
    label_Identifiant=NULL;
    label_titre_Identifiant=NULL;

    hsep5_Identifiant=NULL;
    hsep3_Identifiant=NULL;
    hsep4_Identifiant=NULL;
    hsep2_Identifiant=NULL;
    hsep1_Identifiant=NULL;
    entry_Identifiant=NULL;
    entry_mdp_Identifiant=NULL;
    bouton_valider_Identifiant=NULL;

    FenIdentification=gtk_window_new(GTK_WINDOW_TOPLEVEL);

    tablePrincipal_Identifiant=(GtkWidget*)gtk_table_new(11,1,FALSE);

    hsep1_Identifiant=(GtkHSeparator*)gtk_hseparator_new();
    hsep2_Identifiant=(GtkHSeparator*)gtk_hseparator_new();
    hsep3_Identifiant=(GtkHSeparator*)gtk_hseparator_new();
    hsep4_Identifiant=(GtkHSeparator*)gtk_hseparator_new();
    hsep5_Identifiant=(GtkHSeparator*)gtk_hseparator_new();


    label_titre_Identifiant   =(GtkLabel*)gtk_label_new("Identification");
    label_Identifiant         =(GtkLabel*)gtk_label_new("Identifiant");
    label_mdp_Identifiant     =(GtkLabel*)gtk_label_new("Mot de passe");

    entry_Identifiant         =(GtkEntry*)gtk_entry_new();
    gtk_entry_set_text(entry_Identifiant,"Identifiant");
    entry_mdp_Identifiant     =(GtkEntry*)gtk_entry_new();
    gtk_entry_set_visibility(entry_mdp_Identifiant,FALSE);
    gtk_entry_set_text(entry_mdp_Identifiant,"**********");
    hbox1_Identifiant=(GtkHBox*)gtk_hbox_new(TRUE,3);
    hbox2_Identifiant=(GtkHBox*)gtk_hbox_new(TRUE,3);
    hbox3_Identifiant=(GtkHBox*)gtk_hbox_new(TRUE,3);
    hbox4_Identifiant=(GtkHBox*)gtk_hbox_new(TRUE,3);

    bouton_valider_Identifiant=(GtkButton*)gtk_button_new_with_label("Valider");

    gtk_window_set_modal(GTK_WINDOW(FenIdentification),TRUE);
    gtk_container_add(GTK_CONTAINER(FenIdentification),tablePrincipal_Identifiant);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_Identifiant),GTK_WIDGET(hbox1_Identifiant)     ,0,1,0,1);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_Identifiant),GTK_WIDGET(hsep1_Identifiant)     ,0,1,1,2);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_Identifiant),GTK_WIDGET(hbox2_Identifiant)     ,0,1,2,3);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_Identifiant),GTK_WIDGET(hsep2_Identifiant)     ,0,1,3,4);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_Identifiant),GTK_WIDGET(entry_Identifiant)     ,0,1,4,5);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_Identifiant),GTK_WIDGET(hsep3_Identifiant)     ,0,1,5,6);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_Identifiant),GTK_WIDGET(hbox3_Identifiant)     ,0,1,6,7);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_Identifiant),GTK_WIDGET(hsep4_Identifiant)     ,0,1,7,8);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_Identifiant),GTK_WIDGET(entry_mdp_Identifiant),0,1,8,9);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_Identifiant),GTK_WIDGET(hsep5_Identifiant)    ,0,1,9,10);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_Identifiant),GTK_WIDGET(hbox4_Identifiant)    ,0,1,10,11);

    gtk_box_pack_start(GTK_BOX(hbox1_Identifiant), GTK_WIDGET(label_titre_Identifiant)   , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox2_Identifiant), GTK_WIDGET(label_Identifiant)         , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox3_Identifiant), GTK_WIDGET(label_mdp_Identifiant)     , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox4_Identifiant), GTK_WIDGET(bouton_valider_Identifiant), FALSE, FALSE, 10);
    gtk_window_set_default_size(GTK_WINDOW(FenIdentification),300,200);

    connectSignal_FenetreIdentification();
}
/**********************************************/

void initFenEtudiant()
{
    FenEtudiant=NULL;
    table_ip_Etudiant=NULL;
    tablePrincipal_Etudiant=NULL;
    table_tomuss_Etudiant=NULL;
    image_Etudiant=NULL;
    hsep1_Etudiant=NULL;
    hsep2_Etudiant=NULL;
    hsep3_Etudiant=NULL;
    hsep4_Etudiant=NULL;
    vsep1_Etudiant=NULL;
    vsep2_Etudiant=NULL;
    vsep3_Etudiant=NULL;
    label_numEtu_Etudaint=NULL;
    label_nomEtu_Etudaint=NULL;
    label_prenomEtu_Etudaint=NULL;
    label_ip_Etudaint=NULL;
    label_tomuss_Etudaint=NULL;
    label_cours_Etudaint=NULL;
    textview_Etudiant=NULL;
    hbox1_Etudiant=NULL;
    hbox2_Etudiant=NULL;
    bouton_deconnection_Etudiant=NULL;


    FenEtudiant=gtk_window_new(GTK_WINDOW_TOPLEVEL);
    tablePrincipal_Etudiant=(GtkWidget*)gtk_table_new(12,1,FALSE);
    table_ip_Etudiant      =(GtkWidget*)gtk_table_new(1,1,FALSE);
    table_tomuss_Etudiant  =(GtkWidget*)gtk_table_new(1,1,FALSE);
    image_Etudiant=gtk_image_new();


    hsep1_Etudiant=(GtkHSeparator*)gtk_hseparator_new();
    hsep2_Etudiant=(GtkHSeparator*)gtk_hseparator_new();
    hsep3_Etudiant=(GtkHSeparator*)gtk_hseparator_new();
    hsep4_Etudiant=(GtkHSeparator*)gtk_hseparator_new();

    vsep1_Etudiant=(GtkVSeparator*)gtk_vseparator_new();
    vsep2_Etudiant=(GtkVSeparator*)gtk_vseparator_new();
    vsep3_Etudiant=(GtkVSeparator*)gtk_vseparator_new();

    label_numEtu_Etudaint   =(GtkLabel*)gtk_label_new("numEtu");
    label_nomEtu_Etudaint   =(GtkLabel*)gtk_label_new("nomEtu");
    label_prenomEtu_Etudaint=(GtkLabel*)gtk_label_new("prenomEtu");
    label_ip_Etudaint       =(GtkLabel*)gtk_label_new("Inscription pedagogique");
    label_tomuss_Etudaint   =(GtkLabel*)gtk_label_new("Tomuss");
    label_cours_Etudaint    =(GtkLabel*)gtk_label_new("Vos Cours");

    textview_Etudiant= (GtkTextView*)gtk_text_view_new();
    gtk_text_view_set_justification(textview_Etudiant, GTK_JUSTIFY_CENTER);

    hbox1_Etudiant=(GtkHBox*)gtk_hbox_new(FALSE,7);

    hbox2_Etudiant=(GtkHBox*)gtk_hbox_new(TRUE,3);

    bouton_deconnection_Etudiant=(GtkButton*)gtk_button_new_with_label("Deconnection");

    gtk_window_set_modal(GTK_WINDOW(FenEtudiant),TRUE);
    gtk_container_add(GTK_CONTAINER(FenEtudiant),tablePrincipal_Etudiant);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_Etudiant),GTK_WIDGET(hbox1_Etudiant)       ,0,1,0,1);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_Etudiant),GTK_WIDGET(hsep1_Etudiant)       ,0,1,1,2);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_Etudiant),GTK_WIDGET(label_ip_Etudaint)    ,0,1,2,3);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_Etudiant),GTK_WIDGET(table_ip_Etudiant)    ,0,1,3,4);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_Etudiant),GTK_WIDGET(hsep2_Etudiant)       ,0,1,4,5);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_Etudiant),GTK_WIDGET(label_cours_Etudaint) ,0,1,5,6);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_Etudiant),GTK_WIDGET(textview_Etudiant)    ,0,1,6,7);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_Etudiant),GTK_WIDGET(hsep3_Etudiant)       ,0,1,7,8);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_Etudiant),GTK_WIDGET(label_tomuss_Etudaint),0,1,8,9);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_Etudiant),GTK_WIDGET(table_tomuss_Etudiant),0,1,9,10);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_Etudiant),GTK_WIDGET(hsep4_Etudiant)       ,0,1,10,11);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_Etudiant),GTK_WIDGET(hbox2_Etudiant)       ,0,1,11,12);

    gtk_box_pack_start(GTK_BOX(hbox1_Etudiant), GTK_WIDGET(image_Etudiant)          , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox1_Etudiant), GTK_WIDGET(vsep1_Etudiant)          , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox1_Etudiant), GTK_WIDGET(label_numEtu_Etudaint)   , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox1_Etudiant), GTK_WIDGET(vsep2_Etudiant)          , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox1_Etudiant), GTK_WIDGET(label_nomEtu_Etudaint)   , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox1_Etudiant), GTK_WIDGET(vsep3_Etudiant)          , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox1_Etudiant), GTK_WIDGET(label_prenomEtu_Etudaint), FALSE, FALSE, 10);

    gtk_box_pack_start(GTK_BOX(hbox2_Etudiant), GTK_WIDGET(bouton_deconnection_Etudiant), FALSE, FALSE, 10);
    gtk_window_set_default_size(GTK_WINDOW(FenEtudiant),800,700);

}
/**************************/


/** @brief cb_quit_application_admin
  *
  * @todo: document this function
  */
void cb_quit_application_admin()
{
cb_quit_fenAdmin();
gtk_main_quit();
}

/** @brief cb_quit_application_enseignant
  *
  * @todo: document this function
  */
void cb_quit_application_enseignant()
{
    p_builder=NULL;
    cb_quit_identification();
    gtk_main_quit();
}

void cb_quit_fen_ip()
{

}

/** @brief cb_quit_application_etudiant
  *
  * @todo: document this function
  */
void cb_quit_application_etudiant()
{
    gtk_widget_destroy(image_Etudiant);
    gtk_widget_destroy(GTK_WIDGET(hsep1_Etudiant));
    gtk_widget_destroy(GTK_WIDGET(hsep2_Etudiant));
    gtk_widget_destroy(GTK_WIDGET(hsep3_Etudiant));
    gtk_widget_destroy(GTK_WIDGET(hsep4_Etudiant));

    gtk_widget_destroy(GTK_WIDGET(vsep1_Etudiant));
    gtk_widget_destroy(GTK_WIDGET(vsep2_Etudiant));
    gtk_widget_destroy(GTK_WIDGET(vsep3_Etudiant));

    gtk_widget_destroy(GTK_WIDGET(textview_Etudiant));
    gtk_widget_destroy(GTK_WIDGET(label_numEtu_Etudaint));
    gtk_widget_destroy( GTK_WIDGET(label_nomEtu_Etudaint));
    gtk_widget_destroy(GTK_WIDGET(label_prenomEtu_Etudaint));
    gtk_widget_destroy( GTK_WIDGET(label_ip_Etudaint));
    gtk_widget_destroy(GTK_WIDGET(label_cours_Etudaint));
    gtk_widget_destroy(GTK_WIDGET(label_tomuss_Etudaint));

    gtk_widget_destroy(GTK_WIDGET(bouton_deconnection_Etudiant));

    gtk_widget_destroy(table_ip_Etudiant);
    gtk_widget_destroy( table_tomuss_Etudiant);
    gtk_widget_destroy(GTK_WIDGET(hbox1_Etudiant));
    gtk_widget_destroy(GTK_WIDGET(hbox2_Etudiant));
    gtk_widget_destroy(tablePrincipal_Etudiant);
    gtk_widget_destroy(FenEtudiant);

    cb_quit_identification();
    gtk_main_quit();
}



void    reAfficheFenetreIdentification()
{
    gtk_window_set_default_size(GTK_WINDOW(FenIdentification),300,200);
    gtk_widget_show_all(FenIdentification);
}


void    cb_quit_identification()
{
    gtk_widget_destroy(GTK_WIDGET(label_titre_Identifiant));
    gtk_widget_destroy(GTK_WIDGET(label_Identifiant));
    gtk_widget_destroy(GTK_WIDGET(label_mdp_Identifiant));

    gtk_widget_destroy(GTK_WIDGET(entry_Identifiant));
    gtk_widget_destroy(GTK_WIDGET(entry_mdp_Identifiant));

    gtk_widget_destroy(GTK_WIDGET(bouton_valider_Identifiant));

    gtk_widget_destroy(GTK_WIDGET(hsep1_Identifiant));
    gtk_widget_destroy(GTK_WIDGET(hsep2_Identifiant));
    gtk_widget_destroy(GTK_WIDGET(hsep3_Identifiant));
    gtk_widget_destroy(GTK_WIDGET(hsep4_Identifiant));
    gtk_widget_destroy(GTK_WIDGET(hsep5_Identifiant));

    gtk_widget_destroy(GTK_WIDGET(hbox1_Identifiant));
    gtk_widget_destroy(GTK_WIDGET(hbox2_Identifiant));
    gtk_widget_destroy(GTK_WIDGET(hbox3_Identifiant));
    gtk_widget_destroy(GTK_WIDGET(hbox4_Identifiant));

    gtk_widget_destroy(GTK_WIDGET(tablePrincipal_Identifiant));

    gtk_widget_destroy(GTK_WIDGET(FenIdentification));


    FenIdentification=NULL;
    hbox4_Identifiant=NULL;
    hbox3_Identifiant=NULL;
    hbox1_Identifiant=NULL;
    hbox2_Identifiant=NULL;

    label_mdp_Identifiant=NULL;
    label_Identifiant=NULL;
    label_titre_Identifiant=NULL;

    hsep5_Identifiant=NULL;
    hsep3_Identifiant=NULL;
    hsep4_Identifiant=NULL;
    hsep2_Identifiant=NULL;
    hsep1_Identifiant=NULL;
    entry_Identifiant=NULL;
    entry_mdp_Identifiant=NULL;
    bouton_valider_Identifiant=NULL;
}



void    cb_quit_fenIp()
{
    gtk_widget_destroy(GTK_WIDGET(sep1));
    gtk_widget_destroy(GTK_WIDGET(sep2));
    gtk_widget_destroy(GTK_WIDGET(sep3));

    gtk_widget_destroy(GTK_WIDGET(label_enseignement_presence));

    gtk_widget_destroy(GTK_WIDGET(inscrireBouton));
    gtk_widget_destroy(GTK_WIDGET(desinscrireBouton));


    gtk_widget_destroy(GTK_WIDGET(table_bouton_fen_ip));
    gtk_widget_destroy(GTK_WIDGET(table_ue));
    gtk_widget_destroy(GTK_WIDGET(table_ue_etu));
    gtk_widget_destroy(GTK_WIDGET(table_etu));


    gtk_widget_destroy(GTK_WIDGET(scrollTableUe));
    gtk_widget_destroy(GTK_WIDGET(scrollWinTableEtu));

    gtk_widget_destroy(GTK_WIDGET(tablePrincipal));
    gtk_widget_destroy(GTK_WIDGET(windowFenIp));
}


void    cb_quit_fenPresence()
{
    gtk_widget_destroy(GTK_WIDGET(sep1_Presence));
    gtk_widget_destroy(GTK_WIDGET(sep2_Presence));

    gtk_widget_destroy(GTK_WIDGET(label_enseignement_presence));

    gtk_widget_destroy(GTK_WIDGET(bouton_valider_presence));

    gtk_widget_destroy(GTK_WIDGET(table_etu_Presence));

    gtk_widget_destroy(GTK_WIDGET(scrollWinTableEtuPrecence));

    gtk_widget_destroy(GTK_WIDGET(windowFenPresence));
}


void    cb_quit_fenDefGroupe()
{
    gtk_widget_destroy(GTK_WIDGET(label_NumUE_DefGroupe));
    gtk_widget_destroy(GTK_WIDGET(label_nb_DefGroupe));

    gtk_widget_destroy(GTK_WIDGET(sep1_DefGroupe));
    gtk_widget_destroy(GTK_WIDGET(sep2_DefGroupe));
    gtk_widget_destroy(GTK_WIDGET(sep3_DefGroupe));

    gtk_widget_destroy(GTK_WIDGET(bouton_valider_DefGroupe));

    gtk_widget_destroy(GTK_WIDGET(combboxDefGroupe));

    gtk_widget_destroy(GTK_WIDGET(hbox1_DefGroupe));
    gtk_widget_destroy(GTK_WIDGET(hbox2_DefGroupe));

    gtk_widget_destroy(GTK_WIDGET(tablePrincipal_DefGroupe));

    gtk_widget_destroy(GTK_WIDGET(FenDefGroupe));
    label_NumUE_DefGroupe=NULL;
    label_nb_DefGroupe=NULL;
    sep1_DefGroupe=NULL;
    sep2_DefGroupe=NULL;
    sep3_DefGroupe=NULL;
    bouton_valider_DefGroupe=NULL;
    hbox1_DefGroupe=NULL;
    hbox2_DefGroupe=NULL;
    tablePrincipal_DefGroupe=NULL;
    FenDefGroupe=NULL;
}




void initFenGestionUE()
{
    FenGestionUE=gtk_window_new(GTK_WINDOW_TOPLEVEL);

    tablePrincipal_GestionUE=(GtkWidget*)gtk_table_new(23,1,FALSE);


    hbox1_GestionUE=(GtkHBox*)gtk_hbox_new(TRUE,4);
    hbox2_GestionUE=(GtkHBox*)gtk_hbox_new(TRUE,3);
    hbox3_GestionUE=(GtkHBox*)gtk_hbox_new(TRUE,3);
    hbox4_GestionUE=(GtkHBox*)gtk_hbox_new(TRUE,3);
    hbox5_GestionUE=(GtkHBox*)gtk_hbox_new(TRUE,3);
    hbox6_GestionUE=(GtkHBox*)gtk_hbox_new(TRUE,3);
    hbox7_GestionUE=(GtkHBox*)gtk_hbox_new(TRUE,3);
    hbox8_GestionUE=(GtkHBox*)gtk_hbox_new(TRUE,3);
    hbox9_GestionUE=(GtkHBox*)gtk_hbox_new(TRUE,3);
    hbox10_GestionUE=(GtkHBox*)gtk_hbox_new(TRUE,3);
    hbox11_GestionUE=(GtkHBox*)gtk_hbox_new(TRUE,3);

    hbox_enseignantCM_GestionUE =(GtkHBox*)gtk_hbox_new(TRUE,0);
    hbox_chargeTD_GestionUE     =(GtkHBox*)gtk_hbox_new(TRUE,0);
    hbox_chargeTP_GestionUE     =(GtkHBox*)gtk_hbox_new(TRUE,0);
    hbox_CM_GestionUE           =(GtkHBox*)gtk_hbox_new(TRUE,0);
    hbox_TD_GestionUE           =(GtkHBox*)gtk_hbox_new(TRUE,0);
    hbox_TP_GestionUE           =(GtkHBox*)gtk_hbox_new(TRUE,0);
    hbox_evaluation_GestionUE   =(GtkHBox*)gtk_hbox_new(TRUE,0);
    hbox_moyenne_GestionUE      =(GtkHBox*)gtk_hbox_new(TRUE,0);

    hsep1_GestionUE=(GtkHSeparator*)gtk_hseparator_new();
    hsep2_GestionUE=(GtkHSeparator*)gtk_hseparator_new();
    hsep3_GestionUE=(GtkHSeparator*)gtk_hseparator_new();
    hsep4_GestionUE=(GtkHSeparator*)gtk_hseparator_new();
    hsep5_GestionUE=(GtkHSeparator*)gtk_hseparator_new();
    hsep6_GestionUE=(GtkHSeparator*)gtk_hseparator_new();
    hsep7_GestionUE=(GtkHSeparator*)gtk_hseparator_new();



    label_titre_GestionUE         =(GtkLabel*)gtk_label_new("Gestion de l'Unite d' Enseignement:");
    label_nbEtu_GestionUE         =(GtkLabel*)gtk_label_new("nbEtu");
    label_nbGroupe_GestionUE      =(GtkLabel*)gtk_label_new("nbGroupe");
    label_codeUE_GestionUE          =(GtkLabel*)gtk_label_new("codeUE");

    label_respUE_GestionUE        =(GtkLabel*)gtk_label_new("Responsable de l'ue	:");
    label_enseignantCM_GestionUE  =(GtkLabel*)gtk_label_new("Enseignant CM");
    label_chargeTD_GestionUE      =(GtkLabel*)gtk_label_new("chargeTD");
    label_chargeTP_GestionUE      =(GtkLabel*)gtk_label_new("chargeTP");

    label_enseigementUE_GestionUE =(GtkLabel*)gtk_label_new("Enseignement de l'UE");
    label_CM_GestionUE            =(GtkLabel*)gtk_label_new("CM");
    label_TD_GestionUE            =(GtkLabel*)gtk_label_new("TD");
    label_TP_GestionUE            =(GtkLabel*)gtk_label_new("TP");

    label_evaluation_GestionUE    =(GtkLabel*)gtk_label_new("Evaluation");
    label_listEvaluation_GestionUE=(GtkLabel*)gtk_label_new("Listes des evaluations");

    label_noteUE_GestionUE=(GtkLabel*)gtk_label_new("Notes de l'UE");
    label_moyenneUE_GestionUE=(GtkLabel*)gtk_label_new("Moyenne de l'UE");

    bouton_defgroupe_GestionUE                =(GtkButton*)gtk_button_new_with_label("Definir les groupes");
    bouton_modif_enseignantCM_GestionUE  =(GtkButton*)gtk_button_new_with_label("Modifier");
    bouton_modif_chargeTD_GestionUE      =(GtkButton*)gtk_button_new_with_label("Modifier");
    bouton_modif_chargeTP_GestionUE      =(GtkButton*)gtk_button_new_with_label("Modifier");
    bouton_modif_CM_GestionUE            =(GtkButton*)gtk_button_new_with_label("Modifier");
    bouton_modif_TD_GestionUE            =(GtkButton*)gtk_button_new_with_label("Modifier");
    bouton_modif_TP_GestionUE            =(GtkButton*)gtk_button_new_with_label("Modifier");
    bouton_modif_evaluation_GestionUE    =(GtkButton*)gtk_button_new_with_label("Modifier");
    bouton_noteEtu_GestionUE             =(GtkButton*)gtk_button_new_with_label("Notes des etudiants");
    bouton_valoriser_GestionUE           =(GtkButton*)gtk_button_new_with_label("Valoriser");
    bouton_fermer_GestionUE              =(GtkButton*)gtk_button_new_with_label("Fermer");

    bouton_link_GestionUE                =(GtkLinkButton*)gtk_link_button_new("Correspondre avec L'UE");
    gtk_link_button_set_uri(bouton_link_GestionUE, "mailto:ue@etu.univ-lyon1.fr");

    gtk_window_set_modal(GTK_WINDOW(FenGestionUE),TRUE);
    gtk_container_add(GTK_CONTAINER(FenGestionUE),tablePrincipal_GestionUE);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_GestionUE),GTK_WIDGET(label_titre_GestionUE)        ,0,1,0,1);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_GestionUE),GTK_WIDGET(hsep1_GestionUE)              ,0,1,1,2);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_GestionUE),GTK_WIDGET(hbox1_GestionUE)              ,0,1,2,3);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_GestionUE),GTK_WIDGET(hsep2_GestionUE)              ,0,1,3,4);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_GestionUE),GTK_WIDGET(label_respUE_GestionUE)       ,0,1,4,5);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_GestionUE),GTK_WIDGET(hbox2_GestionUE)              ,0,1,5,6);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_GestionUE),GTK_WIDGET(hbox3_GestionUE)              ,0,1,6,7);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_GestionUE),GTK_WIDGET(hbox4_GestionUE)              ,0,1,7,8);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_GestionUE),GTK_WIDGET(hsep3_GestionUE)              ,0,1,8,9);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_GestionUE),GTK_WIDGET(label_enseigementUE_GestionUE),0,1,9,10);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_GestionUE),GTK_WIDGET(hbox5_GestionUE)            ,0,1,10,11);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_GestionUE),GTK_WIDGET(hbox6_GestionUE)            ,0,1,11,12);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_GestionUE),GTK_WIDGET(hbox7_GestionUE)            ,0,1,12,13);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_GestionUE),GTK_WIDGET(hsep4_GestionUE)              ,0,1,13,14);


    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_GestionUE),GTK_WIDGET(label_evaluation_GestionUE)   ,0,1,14,15);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_GestionUE),GTK_WIDGET(hbox8_GestionUE)              ,0,1,15,16);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_GestionUE),GTK_WIDGET(hsep5_GestionUE)              ,0,1,16,17);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_GestionUE),GTK_WIDGET(label_moyenneUE_GestionUE)       ,0,1,17,18);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_GestionUE),GTK_WIDGET(hbox9_GestionUE)              ,0,1,18,19);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_GestionUE),GTK_WIDGET(hsep6_GestionUE)              ,0,1,19,20);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_GestionUE),GTK_WIDGET(hbox10_GestionUE)             ,0,1,20,21);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_GestionUE),GTK_WIDGET(hsep7_GestionUE)              ,0,1,21,22);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_GestionUE),GTK_WIDGET(hbox11_GestionUE)             ,0,1,22,23);



    gtk_box_pack_start(GTK_BOX(hbox1_GestionUE), GTK_WIDGET(label_nbEtu_GestionUE)     , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox1_GestionUE), GTK_WIDGET(label_nbGroupe_GestionUE)  , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox1_GestionUE), GTK_WIDGET(label_codeUE_GestionUE)    , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox1_GestionUE), GTK_WIDGET(bouton_defgroupe_GestionUE), FALSE, FALSE, 10);


    gtk_box_pack_start(GTK_BOX(hbox2_GestionUE), GTK_WIDGET(label_enseignantCM_GestionUE)   , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox2_GestionUE), GTK_WIDGET(hbox_enseignantCM_GestionUE)    , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox2_GestionUE), GTK_WIDGET(bouton_modif_enseignantCM_GestionUE), FALSE, FALSE, 10);

    gtk_box_pack_start(GTK_BOX(hbox3_GestionUE), GTK_WIDGET(label_chargeTD_GestionUE)       , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox3_GestionUE), GTK_WIDGET(hbox_chargeTD_GestionUE)        , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox3_GestionUE), GTK_WIDGET(bouton_modif_chargeTD_GestionUE), FALSE, FALSE, 10);

    gtk_box_pack_start(GTK_BOX(hbox4_GestionUE), GTK_WIDGET(label_chargeTP_GestionUE)       , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox4_GestionUE), GTK_WIDGET(hbox_chargeTP_GestionUE)        , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox4_GestionUE), GTK_WIDGET(bouton_modif_chargeTP_GestionUE), FALSE, FALSE, 10);

    gtk_box_pack_start(GTK_BOX(hbox5_GestionUE), GTK_WIDGET(label_CM_GestionUE)       , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox5_GestionUE), GTK_WIDGET(hbox_CM_GestionUE)        , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox5_GestionUE), GTK_WIDGET(bouton_modif_CM_GestionUE), FALSE, FALSE, 10);

    gtk_box_pack_start(GTK_BOX(hbox6_GestionUE), GTK_WIDGET(label_TD_GestionUE)       , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox6_GestionUE), GTK_WIDGET(hbox_TD_GestionUE)        , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox6_GestionUE), GTK_WIDGET(bouton_modif_TD_GestionUE), FALSE, FALSE, 10);

    gtk_box_pack_start(GTK_BOX(hbox7_GestionUE), GTK_WIDGET(label_TP_GestionUE)       , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox7_GestionUE), GTK_WIDGET(hbox_TP_GestionUE)        , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox7_GestionUE), GTK_WIDGET(bouton_modif_TP_GestionUE), FALSE, FALSE, 10);

    gtk_box_pack_start(GTK_BOX(hbox8_GestionUE), GTK_WIDGET(label_listEvaluation_GestionUE)   , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox8_GestionUE), GTK_WIDGET(hbox_evaluation_GestionUE)        , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox8_GestionUE), GTK_WIDGET(bouton_modif_evaluation_GestionUE), FALSE, FALSE, 10);

    gtk_box_pack_start(GTK_BOX(hbox9_GestionUE), GTK_WIDGET(label_noteUE_GestionUE)    , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox9_GestionUE), GTK_WIDGET(hbox_moyenne_GestionUE)    , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox9_GestionUE), GTK_WIDGET(bouton_valoriser_GestionUE), FALSE, FALSE, 10);

    gtk_box_pack_start(GTK_BOX(hbox10_GestionUE), GTK_WIDGET(bouton_noteEtu_GestionUE) , FALSE, FALSE, 10);

    gtk_box_pack_start(GTK_BOX(hbox11_GestionUE), GTK_WIDGET(bouton_link_GestionUE)    , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox11_GestionUE), GTK_WIDGET(bouton_fermer_GestionUE)  , FALSE, FALSE, 10);

    gtk_window_set_default_size(GTK_WINDOW(FenIdentification),300,200);
}

void    cb_quit_fenGestionUE()
{
    gtk_widget_destroy(GTK_WIDGET(label_NumUE_DefGroupe));
    gtk_widget_destroy(GTK_WIDGET(label_titre_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(label_nbEtu_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(label_nbGroupe_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(label_codeUE_GestionUE));

    gtk_widget_destroy(GTK_WIDGET(label_respUE_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(label_enseignantCM_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(label_chargeTD_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(label_chargeTP_GestionUE));

    gtk_widget_destroy(GTK_WIDGET(label_enseigementUE_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(label_CM_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(label_TD_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(label_TP_GestionUE));

    gtk_widget_destroy(GTK_WIDGET(label_evaluation_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(label_listEvaluation_GestionUE));

    gtk_widget_destroy(GTK_WIDGET(label_noteUE_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(label_moyenneUE_GestionUE));


    gtk_widget_destroy(GTK_WIDGET(hsep1_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(hsep2_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(hsep3_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(hsep4_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(hsep5_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(hsep6_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(hsep7_GestionUE));


    gtk_widget_destroy(GTK_WIDGET(bouton_valider_DefGroupe));
    gtk_widget_destroy(GTK_WIDGET(bouton_defgroupe_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(bouton_modif_enseignantCM_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(bouton_modif_chargeTD_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(bouton_modif_chargeTP_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(bouton_modif_CM_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(bouton_modif_TD_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(bouton_modif_TP_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(bouton_modif_evaluation_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(bouton_noteEtu_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(bouton_valoriser_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(bouton_fermer_GestionUE));

    gtk_widget_destroy(GTK_WIDGET(bouton_link_GestionUE));

    gtk_widget_destroy(GTK_WIDGET(hbox1_DefGroupe));
    gtk_widget_destroy(GTK_WIDGET(hbox_enseignantCM_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(hbox_chargeTD_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(hbox_chargeTP_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(hbox_CM_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(hbox_TD_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(hbox_TP_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(hbox_evaluation_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(hbox_moyenne_GestionUE));

    gtk_widget_destroy(GTK_WIDGET(hbox1_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(hbox2_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(hbox3_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(hbox4_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(hbox5_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(hbox6_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(hbox7_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(hbox8_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(hbox9_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(hbox10_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(hbox11_GestionUE));


    gtk_widget_destroy(GTK_WIDGET(tablePrincipal_GestionUE));
    gtk_widget_destroy(GTK_WIDGET(FenGestionUE));



    label_NumUE_DefGroupe = NULL;
    label_titre_GestionUE = NULL;
    label_nbEtu_GestionUE = NULL;
    label_nbGroupe_GestionUE = NULL;
    label_codeUE_GestionUE = NULL;

    label_respUE_GestionUE = NULL;
    label_enseignantCM_GestionUE = NULL;
    label_chargeTD_GestionUE = NULL;
    label_chargeTP_GestionUE = NULL;

    label_enseigementUE_GestionUE = NULL;
    label_CM_GestionUE = NULL;
    label_TD_GestionUE = NULL;
    label_TP_GestionUE = NULL;

    label_evaluation_GestionUE = NULL;
    label_listEvaluation_GestionUE = NULL;

    label_noteUE_GestionUE = NULL;
    label_moyenneUE_GestionUE = NULL;


    hsep1_GestionUE = NULL;
    hsep2_GestionUE = NULL;
    hsep3_GestionUE = NULL;
    hsep4_GestionUE = NULL;
    hsep5_GestionUE = NULL;
    hsep6_GestionUE = NULL;
    hsep7_GestionUE = NULL;


    bouton_valider_DefGroupe = NULL;
    bouton_defgroupe_GestionUE = NULL;
    bouton_modif_enseignantCM_GestionUE = NULL;
    bouton_modif_chargeTD_GestionUE = NULL;
    bouton_modif_chargeTP_GestionUE = NULL;
    bouton_modif_CM_GestionUE = NULL;
    bouton_modif_TD_GestionUE = NULL;
    bouton_modif_TP_GestionUE = NULL;
    bouton_modif_evaluation_GestionUE = NULL;
    bouton_noteEtu_GestionUE = NULL;
    bouton_valoriser_GestionUE = NULL;
    bouton_fermer_GestionUE = NULL;

    bouton_link_GestionUE = NULL;

    hbox1_DefGroupe = NULL;
    hbox_enseignantCM_GestionUE = NULL;
    hbox_chargeTD_GestionUE = NULL;
    hbox_chargeTP_GestionUE = NULL;
    hbox_CM_GestionUE = NULL;
    hbox_TD_GestionUE = NULL;
    hbox_TP_GestionUE = NULL;
    hbox_evaluation_GestionUE = NULL;
    hbox_moyenne_GestionUE = NULL;

    hbox1_GestionUE = NULL;
    hbox2_GestionUE = NULL;
    hbox3_GestionUE = NULL;
    hbox4_GestionUE = NULL;
    hbox5_GestionUE = NULL;
    hbox6_GestionUE = NULL;
    hbox7_GestionUE = NULL;
    hbox8_GestionUE = NULL;
    hbox9_GestionUE = NULL;
    hbox10_GestionUE = NULL;
    hbox11_GestionUE = NULL;


    tablePrincipal_GestionUE = NULL;
    FenGestionUE = NULL;




}




/************Fenetre Admin****************/

void initFenAdmin()
{
    FenAdmin=gtk_window_new(GTK_WINDOW_TOPLEVEL);

    tablePrincipal_Admin=(GtkWidget*)gtk_table_new(10,1,FALSE);


    hbox1_Admin=(GtkHBox*)gtk_hbox_new(TRUE,4);
    hbox2_Admin=(GtkHBox*)gtk_hbox_new(TRUE,3);
    hbox3_Admin=(GtkHBox*)gtk_hbox_new(TRUE,3);
    hbox4_Admin=(GtkHBox*)gtk_hbox_new(TRUE,3);
    hbox5_Admin=(GtkHBox*)gtk_hbox_new(TRUE,3);

    hsep1_Admin=(GtkHSeparator*)gtk_hseparator_new();
    hsep2_Admin=(GtkHSeparator*)gtk_hseparator_new();
    hsep3_Admin=(GtkHSeparator*)gtk_hseparator_new();
    hsep4_Admin=(GtkHSeparator*)gtk_hseparator_new();

    label_titre_Admin         =(GtkLabel*)gtk_label_new("   Administrateur  ");


    bouton_AjoutEtu_Admin    =(GtkButton*)gtk_button_new_with_label("Ajouter Un Etudiant");
    bouton_AjoutEns_Admin    =(GtkButton*)gtk_button_new_with_label("Ajouter Un Enseignant");
    bouton_AjoutUE_Admin     =(GtkButton*)gtk_button_new_with_label("Ajouter Un UE");
    bouton_AjoutSalle_Admin  =(GtkButton*)gtk_button_new_with_label("Ajouter Une Salle");


    gtk_window_set_modal(GTK_WINDOW(FenAdmin),TRUE);
    gtk_container_add(GTK_CONTAINER(FenAdmin),tablePrincipal_Admin);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_Admin),GTK_WIDGET(label_titre_Admin)        ,0,1,0,1);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_Admin),GTK_WIDGET(hsep1_Admin)              ,0,1,1,2);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_Admin),GTK_WIDGET(hbox1_Admin)              ,0,1,2,3);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_Admin),GTK_WIDGET(hsep2_Admin)              ,0,1,3,4);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_Admin),GTK_WIDGET(hbox2_Admin)              ,0,1,4,5);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_Admin),GTK_WIDGET(hsep3_Admin)              ,0,1,5,6);


    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_Admin),GTK_WIDGET(hbox3_Admin)              ,0,1,6,7);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_Admin),GTK_WIDGET(hsep4_Admin)              ,0,1,7,8);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_Admin),GTK_WIDGET(hbox4_Admin)              ,0,1,8,9);

    gtk_box_pack_start(GTK_BOX(hbox1_Admin), GTK_WIDGET(bouton_AjoutEtu_Admin)  , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox2_Admin), GTK_WIDGET(bouton_AjoutEns_Admin)  , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox3_Admin), GTK_WIDGET(bouton_AjoutUE_Admin)   , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox4_Admin), GTK_WIDGET(bouton_AjoutSalle_Admin), FALSE, FALSE, 10);


    gtk_window_set_default_size(GTK_WINDOW(FenAdmin),300,200);
}

void    cb_quit_fenAdmin()
{
    gtk_widget_destroy(GTK_WIDGET(hsep1_Admin));
    gtk_widget_destroy(GTK_WIDGET(hsep2_Admin));
    gtk_widget_destroy(GTK_WIDGET(hsep3_Admin));
    gtk_widget_destroy(GTK_WIDGET(hsep4_Admin));

    gtk_widget_destroy(GTK_WIDGET(label_titre_Admin));

    gtk_widget_destroy(GTK_WIDGET(bouton_AjoutEtu_Admin));
    gtk_widget_destroy(GTK_WIDGET(bouton_AjoutEns_Admin));
    gtk_widget_destroy(GTK_WIDGET(bouton_AjoutUE_Admin));
    gtk_widget_destroy(GTK_WIDGET(bouton_AjoutSalle_Admin));

    gtk_widget_destroy(GTK_WIDGET(hbox1_Admin));
    gtk_widget_destroy(GTK_WIDGET(hbox2_Admin));
    gtk_widget_destroy(GTK_WIDGET(hbox3_Admin));
    gtk_widget_destroy(GTK_WIDGET(hbox4_Admin));
    gtk_widget_destroy(GTK_WIDGET(hbox5_Admin));

    gtk_widget_destroy(GTK_WIDGET(tablePrincipal_Admin));
    gtk_widget_destroy(GTK_WIDGET(FenAdmin));

}
/*****************************************************/
/***Fenetre AjoutEns***/
void initFenAjoutEns()
{

    FenAjoutEns=gtk_window_new(GTK_WINDOW_TOPLEVEL);

    tablePrincipal_AjoutEns=(GtkWidget*)gtk_table_new(12,1,FALSE);

    hsep1_AjoutEns=(GtkHSeparator*)gtk_hseparator_new();
    hsep2_AjoutEns=(GtkHSeparator*)gtk_hseparator_new();
    hsep3_AjoutEns=(GtkHSeparator*)gtk_hseparator_new();
    hsep4_AjoutEns=(GtkHSeparator*)gtk_hseparator_new();


    label_titre_AjoutEns        =(GtkLabel*)gtk_label_new("Ajouter Nouveau Enseignant");
    label_numEns_AjoutEns       =(GtkLabel*)gtk_label_new("Numero Enseignant");
    label_nomEns_AjoutEns       =(GtkLabel*)gtk_label_new("Nom Enseignant");
    label_prenomEns_AjoutEns    =(GtkLabel*)gtk_label_new("Prenom Enseignant");

    entry_numEns_AjoutEns       =(GtkEntry*)gtk_entry_new();
    gtk_entry_set_text(entry_numEns_AjoutEns,"Numero Enseignant");
    entry_nomEns_AjoutEns       =(GtkEntry*)gtk_entry_new();
    gtk_entry_set_text(entry_nomEns_AjoutEns,"Nom Enseignant");
    entry_prenomEns_AjoutEns    =(GtkEntry*)gtk_entry_new();
    gtk_entry_set_text(entry_prenomEns_AjoutEns,"Prenom Enseignant");

    hbox1_AjoutEns=(GtkHBox*)gtk_hbox_new(TRUE,3);
    hbox2_AjoutEns=(GtkHBox*)gtk_hbox_new(TRUE,3);
    hbox3_AjoutEns=(GtkHBox*)gtk_hbox_new(TRUE,3);
    hbox4_AjoutEns=(GtkHBox*)gtk_hbox_new(TRUE,3);


    bouton_valider_AjoutEns=(GtkButton*)gtk_button_new_with_label("Valider");

    gtk_window_set_modal(GTK_WINDOW(FenAjoutEns),TRUE);
    gtk_container_add(GTK_CONTAINER(FenAjoutEns),tablePrincipal_AjoutEns);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutEns),GTK_WIDGET(label_titre_AjoutEns)     ,0,1,0,1);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutEns),GTK_WIDGET(hsep1_AjoutEns)     ,0,1,1,2);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutEns),GTK_WIDGET(hbox1_AjoutEns)        ,0,1,2,3);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutEns),GTK_WIDGET(hsep2_AjoutEns)        ,0,1,3,4);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutEns),GTK_WIDGET(entry_numEns_AjoutEns) ,0,1,4,5);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutEns),GTK_WIDGET(hbox2_AjoutEns)        ,0,1,5,6);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutEns),GTK_WIDGET(hsep3_AjoutEns)        ,0,1,6,7);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutEns),GTK_WIDGET(entry_nomEns_AjoutEns) ,0,1,7,8);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutEns),GTK_WIDGET(hbox3_AjoutEns)        ,0,1,8,9);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutEns),GTK_WIDGET(hsep4_AjoutEns)        ,0,1,9,10);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutEns),GTK_WIDGET(entry_prenomEns_AjoutEns) ,0,1,10,11);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutEns),GTK_WIDGET(hbox4_AjoutEns)        ,0,1,11,12);

    gtk_box_pack_start(GTK_BOX(hbox1_AjoutEns), GTK_WIDGET(label_numEns_AjoutEns)    , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox2_AjoutEns), GTK_WIDGET(label_nomEns_AjoutEns)    , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox3_AjoutEns), GTK_WIDGET(label_prenomEns_AjoutEns) , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox4_AjoutEns), GTK_WIDGET(bouton_valider_AjoutEns)  , FALSE, FALSE, 10);

    gtk_window_set_default_size(GTK_WINDOW(FenAjoutEns),300,200);
}


void    cb_quit_fenAjoutEns()
{
    gtk_widget_destroy(GTK_WIDGET(label_titre_AjoutEns));
    gtk_widget_destroy(GTK_WIDGET(label_numEns_AjoutEns));
    gtk_widget_destroy(GTK_WIDGET(label_nomEns_AjoutEns));
    gtk_widget_destroy(GTK_WIDGET(label_prenomEns_AjoutEns));

    gtk_widget_destroy(GTK_WIDGET(entry_numEns_AjoutEns));
    gtk_widget_destroy(GTK_WIDGET(entry_nomEns_AjoutEns));
    gtk_widget_destroy(GTK_WIDGET(entry_prenomEns_AjoutEns));

    gtk_widget_destroy(GTK_WIDGET(bouton_valider_AjoutEns));

    gtk_widget_destroy(GTK_WIDGET(hsep1_AjoutEns));
    gtk_widget_destroy(GTK_WIDGET(hsep2_AjoutEns));
    gtk_widget_destroy(GTK_WIDGET(hsep3_AjoutEns));
    gtk_widget_destroy(GTK_WIDGET(hsep4_AjoutEns));

    gtk_widget_destroy(GTK_WIDGET(hbox1_AjoutEns));
    gtk_widget_destroy(GTK_WIDGET(hbox2_AjoutEns));
    gtk_widget_destroy(GTK_WIDGET(hbox3_AjoutEns));
    gtk_widget_destroy(GTK_WIDGET(hbox4_AjoutEns));

    gtk_widget_destroy(GTK_WIDGET(tablePrincipal_AjoutEns));

    gtk_widget_destroy(GTK_WIDGET(FenAjoutEns));

    label_titre_AjoutEns = NULL;
    label_numEns_AjoutEns = NULL;
    label_nomEns_AjoutEns = NULL;
    label_prenomEns_AjoutEns = NULL;

    entry_numEns_AjoutEns = NULL;
    entry_nomEns_AjoutEns = NULL;
    entry_prenomEns_AjoutEns = NULL;

    bouton_valider_AjoutEns = NULL;

    hsep1_AjoutEns = NULL;
    hsep2_AjoutEns = NULL;
    hsep3_AjoutEns = NULL;
    hsep4_AjoutEns = NULL;

    hbox1_AjoutEns = NULL;
    hbox2_AjoutEns = NULL;
    hbox3_AjoutEns = NULL;
    hbox4_AjoutEns = NULL;

    tablePrincipal_AjoutEns = NULL;
    FenAjoutEns = NULL;
}
/*****************************************************/
/***Fenetre AjoutEtu***/
void initFenAjoutEtu()
{

    FenAjoutEtu=gtk_window_new(GTK_WINDOW_TOPLEVEL);

    tablePrincipal_AjoutEtu=(GtkWidget*)gtk_table_new(12,1,FALSE);

    hsep1_AjoutEtu=(GtkHSeparator*)gtk_hseparator_new();
    hsep2_AjoutEtu=(GtkHSeparator*)gtk_hseparator_new();
    hsep3_AjoutEtu=(GtkHSeparator*)gtk_hseparator_new();
    hsep4_AjoutEtu=(GtkHSeparator*)gtk_hseparator_new();


    label_titre_AjoutEtu        =(GtkLabel*)gtk_label_new("Ajouter Nouveau Etudiant");
    label_numEtu_AjoutEtu       =(GtkLabel*)gtk_label_new("Numero Etudiant");
    label_nomEtu_AjoutEtu       =(GtkLabel*)gtk_label_new("Nom Etudiant");
    label_prenomEtu_AjoutEtu    =(GtkLabel*)gtk_label_new("Prenom Etudiant");

    entry_numEtu_AjoutEtu       =(GtkEntry*)gtk_entry_new();
    gtk_entry_set_text(entry_numEtu_AjoutEtu,"Numero Etudiant");
    entry_nomEtu_AjoutEtu       =(GtkEntry*)gtk_entry_new();
    gtk_entry_set_text(entry_nomEtu_AjoutEtu,"Nom Etudiant");
    entry_prenomEtu_AjoutEtu    =(GtkEntry*)gtk_entry_new();
    gtk_entry_set_text(entry_prenomEtu_AjoutEtu,"Prenom Etudiant");

    hbox1_AjoutEtu=(GtkHBox*)gtk_hbox_new(TRUE,3);
    hbox2_AjoutEtu=(GtkHBox*)gtk_hbox_new(TRUE,3);
    hbox3_AjoutEtu=(GtkHBox*)gtk_hbox_new(TRUE,3);
    hbox4_AjoutEtu=(GtkHBox*)gtk_hbox_new(TRUE,3);


    bouton_valider_AjoutEtu=(GtkButton*)gtk_button_new_with_label("Valider");

    gtk_window_set_modal(GTK_WINDOW(FenAjoutEtu),TRUE);
    gtk_container_add(GTK_CONTAINER(FenAjoutEtu),tablePrincipal_AjoutEtu);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutEtu),GTK_WIDGET(label_titre_AjoutEtu)     ,0,1,0,1);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutEtu),GTK_WIDGET(hsep1_AjoutEtu)     ,0,1,1,2);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutEtu),GTK_WIDGET(hbox1_AjoutEtu)        ,0,1,2,3);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutEtu),GTK_WIDGET(hsep2_AjoutEtu)        ,0,1,3,4);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutEtu),GTK_WIDGET(entry_numEtu_AjoutEtu) ,0,1,4,5);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutEtu),GTK_WIDGET(hbox2_AjoutEtu)        ,0,1,5,6);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutEtu),GTK_WIDGET(hsep3_AjoutEtu)        ,0,1,6,7);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutEtu),GTK_WIDGET(entry_nomEtu_AjoutEtu) ,0,1,7,8);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutEtu),GTK_WIDGET(hbox3_AjoutEtu)        ,0,1,8,9);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutEtu),GTK_WIDGET(hsep4_AjoutEtu)        ,0,1,9,10);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutEtu),GTK_WIDGET(entry_prenomEtu_AjoutEtu) ,0,1,10,11);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutEtu),GTK_WIDGET(hbox4_AjoutEtu)        ,0,1,11,12);

    gtk_box_pack_start(GTK_BOX(hbox1_AjoutEtu), GTK_WIDGET(label_numEtu_AjoutEtu)    , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox2_AjoutEtu), GTK_WIDGET(label_nomEtu_AjoutEtu)    , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox3_AjoutEtu), GTK_WIDGET(label_prenomEtu_AjoutEtu) , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox4_AjoutEtu), GTK_WIDGET(bouton_valider_AjoutEtu)  , FALSE, FALSE, 10);

    gtk_window_set_default_size(GTK_WINDOW(FenAjoutEtu),300,200);
}


void    cb_quit_fenAjoutEtu()
{
    gtk_widget_destroy(GTK_WIDGET(label_titre_AjoutEtu));
    gtk_widget_destroy(GTK_WIDGET(label_numEtu_AjoutEtu));
    gtk_widget_destroy(GTK_WIDGET(label_nomEtu_AjoutEtu));
    gtk_widget_destroy(GTK_WIDGET(label_prenomEtu_AjoutEtu));

    gtk_widget_destroy(GTK_WIDGET(entry_numEtu_AjoutEtu));
    gtk_widget_destroy(GTK_WIDGET(entry_nomEtu_AjoutEtu));
    gtk_widget_destroy(GTK_WIDGET(entry_prenomEtu_AjoutEtu));

    gtk_widget_destroy(GTK_WIDGET(bouton_valider_AjoutEtu));

    gtk_widget_destroy(GTK_WIDGET(hsep1_AjoutEtu));
    gtk_widget_destroy(GTK_WIDGET(hsep2_AjoutEtu));
    gtk_widget_destroy(GTK_WIDGET(hsep3_AjoutEtu));
    gtk_widget_destroy(GTK_WIDGET(hsep4_AjoutEtu));

    gtk_widget_destroy(GTK_WIDGET(hbox1_AjoutEtu));
    gtk_widget_destroy(GTK_WIDGET(hbox2_AjoutEtu));
    gtk_widget_destroy(GTK_WIDGET(hbox3_AjoutEtu));
    gtk_widget_destroy(GTK_WIDGET(hbox4_AjoutEtu));

    gtk_widget_destroy(GTK_WIDGET(tablePrincipal_AjoutEtu));

    gtk_widget_destroy(GTK_WIDGET(FenAjoutEtu));

    label_titre_AjoutEtu = NULL;
    label_numEtu_AjoutEtu = NULL;
    label_nomEtu_AjoutEtu = NULL;
    label_prenomEtu_AjoutEtu = NULL;

    entry_numEtu_AjoutEtu = NULL;
    entry_nomEtu_AjoutEtu = NULL;
    entry_prenomEtu_AjoutEtu = NULL;

    bouton_valider_AjoutEtu = NULL;

    hsep1_AjoutEtu = NULL;
    hsep2_AjoutEtu = NULL;
    hsep3_AjoutEtu = NULL;
    hsep4_AjoutEtu = NULL;

    hbox1_AjoutEtu = NULL;
    hbox2_AjoutEtu = NULL;
    hbox3_AjoutEtu = NULL;
    hbox4_AjoutEtu = NULL;

    tablePrincipal_AjoutEtu = NULL;
    FenAjoutEtu = NULL;
}
/*****************************************************/
/***Fenetre AjoutSalle***/
void initFenAjoutSalle()
{

    FenAjoutSalle=gtk_window_new(GTK_WINDOW_TOPLEVEL);

    tablePrincipal_AjoutSalle=(GtkWidget*)gtk_table_new(9,1,FALSE);

    hsep1_AjoutSalle=(GtkHSeparator*)gtk_hseparator_new();
    hsep2_AjoutSalle=(GtkHSeparator*)gtk_hseparator_new();
    hsep3_AjoutSalle=(GtkHSeparator*)gtk_hseparator_new();


    label_titre_AjoutSalle          =(GtkLabel*)gtk_label_new("Ajouter Nouveau Salle");
    label_numSalle_AjoutSalle       =(GtkLabel*)gtk_label_new("Numero Salle");
    label_IntituleSalle_AjoutSalle  =(GtkLabel*)gtk_label_new("Intitule Salle");


    entry_numSalle_AjoutSalle       =(GtkEntry*)gtk_entry_new();
    gtk_entry_set_text(entry_numSalle_AjoutSalle,"Numero Salle");
    entry_IntituleSalle_AjoutSalle       =(GtkEntry*)gtk_entry_new();
    gtk_entry_set_text(entry_IntituleSalle_AjoutSalle,"Intitule Salle");

    hbox1_AjoutSalle=(GtkHBox*)gtk_hbox_new(TRUE,3);
    hbox2_AjoutSalle=(GtkHBox*)gtk_hbox_new(TRUE,3);
    hbox3_AjoutSalle=(GtkHBox*)gtk_hbox_new(TRUE,3);


    bouton_valider_AjoutSalle=(GtkButton*)gtk_button_new_with_label("Valider");

    gtk_window_set_modal(GTK_WINDOW(FenAjoutSalle),TRUE);
    gtk_container_add(GTK_CONTAINER(FenAjoutSalle),tablePrincipal_AjoutSalle);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutSalle),GTK_WIDGET(label_titre_AjoutSalle)    ,0,1,0,1);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutSalle),GTK_WIDGET(hsep1_AjoutSalle)          ,0,1,1,2);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutSalle),GTK_WIDGET(hbox1_AjoutSalle)          ,0,1,2,3);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutSalle),GTK_WIDGET(hsep2_AjoutSalle)          ,0,1,3,4);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutSalle),GTK_WIDGET(entry_numSalle_AjoutSalle) ,0,1,4,5);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutSalle),GTK_WIDGET(hbox2_AjoutSalle)          ,0,1,5,6);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutSalle),GTK_WIDGET(hsep3_AjoutSalle)          ,0,1,6,7);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutSalle),GTK_WIDGET(entry_IntituleSalle_AjoutSalle) ,0,1,7,8);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutSalle),GTK_WIDGET(hbox3_AjoutSalle)          ,0,1,8,9);

    gtk_box_pack_start(GTK_BOX(hbox1_AjoutSalle), GTK_WIDGET(label_numSalle_AjoutSalle)      , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox2_AjoutSalle), GTK_WIDGET(label_IntituleSalle_AjoutSalle) , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox3_AjoutSalle), GTK_WIDGET(bouton_valider_AjoutSalle)      , FALSE, FALSE, 10);

    gtk_window_set_default_size(GTK_WINDOW(FenAjoutSalle),300,200);
}


void cb_quit_fenAjoutSalle()
{
    gtk_widget_destroy(GTK_WIDGET(label_titre_AjoutSalle));
    gtk_widget_destroy(GTK_WIDGET(label_numSalle_AjoutSalle));
    gtk_widget_destroy(GTK_WIDGET(label_IntituleSalle_AjoutSalle));

    gtk_widget_destroy(GTK_WIDGET(entry_numSalle_AjoutSalle));
    gtk_widget_destroy(GTK_WIDGET(entry_IntituleSalle_AjoutSalle));

    gtk_widget_destroy(GTK_WIDGET(bouton_valider_AjoutSalle));

    gtk_widget_destroy(GTK_WIDGET(hsep1_AjoutSalle));
    gtk_widget_destroy(GTK_WIDGET(hsep2_AjoutSalle));
    gtk_widget_destroy(GTK_WIDGET(hsep3_AjoutSalle));


    gtk_widget_destroy(GTK_WIDGET(hbox1_AjoutSalle));
    gtk_widget_destroy(GTK_WIDGET(hbox2_AjoutSalle));
    gtk_widget_destroy(GTK_WIDGET(hbox3_AjoutSalle));


    gtk_widget_destroy(GTK_WIDGET(tablePrincipal_AjoutSalle));

    gtk_widget_destroy(GTK_WIDGET(FenAjoutSalle));

    label_titre_AjoutSalle = NULL;
    label_numSalle_AjoutSalle = NULL;
    label_IntituleSalle_AjoutSalle = NULL;

    entry_numSalle_AjoutSalle = NULL;
    entry_IntituleSalle_AjoutSalle = NULL;

    bouton_valider_AjoutSalle = NULL;

    hsep1_AjoutSalle = NULL;
    hsep2_AjoutSalle = NULL;
    hsep3_AjoutSalle = NULL;


    hbox1_AjoutSalle = NULL;
    hbox2_AjoutSalle = NULL;
    hbox3_AjoutSalle = NULL;


    tablePrincipal_AjoutSalle = NULL;
    FenAjoutSalle = NULL;
}
/*****************************************************/
/***Fenetre AjoutUE***/
void initFenAjoutUE()
{

    FenAjoutUE=gtk_window_new(GTK_WINDOW_TOPLEVEL);

    tablePrincipal_AjoutUE=(GtkWidget*)gtk_table_new(12,1,FALSE);

    hsep1_AjoutUE=(GtkHSeparator*)gtk_hseparator_new();
    hsep2_AjoutUE=(GtkHSeparator*)gtk_hseparator_new();
    hsep3_AjoutUE=(GtkHSeparator*)gtk_hseparator_new();
    hsep4_AjoutUE=(GtkHSeparator*)gtk_hseparator_new();


    label_titre_AjoutUE        =(GtkLabel*)gtk_label_new("Ajouter Nouveau UE");
    label_codeUE_AjoutUE       =(GtkLabel*)gtk_label_new("codeUE");
    label_IntituleUE_AjoutUE   =(GtkLabel*)gtk_label_new("IntituleUE");
    label_SeqenceUE_AjoutUE    =(GtkLabel*)gtk_label_new("SeqenceUE");

    entry_codeUE_AjoutUE       =(GtkEntry*)gtk_entry_new();
    gtk_entry_set_text(entry_codeUE_AjoutUE,"codeUE");
    entry_IntituleUE_AjoutUE       =(GtkEntry*)gtk_entry_new();
    gtk_entry_set_text(entry_IntituleUE_AjoutUE,"IntituleUE");
    entry_SeqenceUE_AjoutUE    =(GtkEntry*)gtk_entry_new();
    gtk_entry_set_text(entry_SeqenceUE_AjoutUE,"SeqenceUE");

    hbox1_AjoutUE=(GtkHBox*)gtk_hbox_new(TRUE,3);
    hbox2_AjoutUE=(GtkHBox*)gtk_hbox_new(TRUE,3);
    hbox3_AjoutUE=(GtkHBox*)gtk_hbox_new(TRUE,3);
    hbox4_AjoutUE=(GtkHBox*)gtk_hbox_new(TRUE,3);


    bouton_valider_AjoutUE=(GtkButton*)gtk_button_new_with_label("Valider");

    gtk_window_set_modal(GTK_WINDOW(FenAjoutUE),TRUE);
    gtk_container_add(GTK_CONTAINER(FenAjoutUE),tablePrincipal_AjoutUE);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutUE),GTK_WIDGET(label_titre_AjoutUE)     ,0,1,0,1);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutUE),GTK_WIDGET(hsep1_AjoutUE)     ,0,1,1,2);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutUE),GTK_WIDGET(hbox1_AjoutUE)        ,0,1,2,3);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutUE),GTK_WIDGET(hsep2_AjoutUE)        ,0,1,3,4);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutUE),GTK_WIDGET(entry_codeUE_AjoutUE) ,0,1,4,5);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutUE),GTK_WIDGET(hbox2_AjoutUE)        ,0,1,5,6);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutUE),GTK_WIDGET(hsep3_AjoutUE)        ,0,1,6,7);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutUE),GTK_WIDGET(entry_IntituleUE_AjoutUE) ,0,1,7,8);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutUE),GTK_WIDGET(hbox3_AjoutUE)        ,0,1,8,9);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutUE),GTK_WIDGET(hsep4_AjoutUE)        ,0,1,9,10);
    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutUE),GTK_WIDGET(entry_SeqenceUE_AjoutUE) ,0,1,10,11);

    gtk_table_attach_defaults(GTK_TABLE(tablePrincipal_AjoutUE),GTK_WIDGET(hbox4_AjoutUE)        ,0,1,11,12);

    gtk_box_pack_start(GTK_BOX(hbox1_AjoutUE), GTK_WIDGET(label_codeUE_AjoutUE)    , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox2_AjoutUE), GTK_WIDGET(label_IntituleUE_AjoutUE)    , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox3_AjoutUE), GTK_WIDGET(label_SeqenceUE_AjoutUE) , FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox4_AjoutUE), GTK_WIDGET(bouton_valider_AjoutUE)  , FALSE, FALSE, 10);

    gtk_window_set_default_size(GTK_WINDOW(FenAjoutUE),300,200);
}


void cb_quit_fenAjoutUE()
{
    gtk_widget_destroy(GTK_WIDGET(label_titre_AjoutUE));
    gtk_widget_destroy(GTK_WIDGET(label_codeUE_AjoutUE));
    gtk_widget_destroy(GTK_WIDGET(label_IntituleUE_AjoutUE));
    gtk_widget_destroy(GTK_WIDGET(label_SeqenceUE_AjoutUE));

    gtk_widget_destroy(GTK_WIDGET(entry_codeUE_AjoutUE));
    gtk_widget_destroy(GTK_WIDGET(entry_IntituleUE_AjoutUE));
    gtk_widget_destroy(GTK_WIDGET(entry_SeqenceUE_AjoutUE));

    gtk_widget_destroy(GTK_WIDGET(bouton_valider_AjoutUE));

    gtk_widget_destroy(GTK_WIDGET(hsep1_AjoutUE));
    gtk_widget_destroy(GTK_WIDGET(hsep2_AjoutUE));
    gtk_widget_destroy(GTK_WIDGET(hsep3_AjoutUE));
    gtk_widget_destroy(GTK_WIDGET(hsep4_AjoutUE));

    gtk_widget_destroy(GTK_WIDGET(hbox1_AjoutUE));
    gtk_widget_destroy(GTK_WIDGET(hbox2_AjoutUE));
    gtk_widget_destroy(GTK_WIDGET(hbox3_AjoutUE));
    gtk_widget_destroy(GTK_WIDGET(hbox4_AjoutUE));

    gtk_widget_destroy(GTK_WIDGET(tablePrincipal_AjoutUE));

    gtk_widget_destroy(GTK_WIDGET(FenAjoutUE));

    label_titre_AjoutUE = NULL;
    label_codeUE_AjoutUE = NULL;
    label_IntituleUE_AjoutUE = NULL;
    label_SeqenceUE_AjoutUE = NULL;

    entry_codeUE_AjoutUE = NULL;
    entry_IntituleUE_AjoutUE = NULL;
    entry_SeqenceUE_AjoutUE = NULL;

    bouton_valider_AjoutUE = NULL;

    hsep1_AjoutUE = NULL;
    hsep2_AjoutUE = NULL;
    hsep3_AjoutUE = NULL;
    hsep4_AjoutUE = NULL;

    hbox1_AjoutUE = NULL;
    hbox2_AjoutUE = NULL;
    hbox3_AjoutUE = NULL;
    hbox4_AjoutUE = NULL;

    tablePrincipal_AjoutUE = NULL;
    FenAjoutUE = NULL;
}
/*****************************************************/
void    connectSignal_FenAdmin()
{
    g_signal_connect(bouton_AjoutEtu_Admin  , "clicked", G_CALLBACK(cb_ouvrir_FenAjoutEtu), NULL);
    g_signal_connect(bouton_AjoutEns_Admin  , "clicked", G_CALLBACK(cb_ouvrir_FenAjoutEns), NULL);
    g_signal_connect(bouton_AjoutUE_Admin   , "clicked", G_CALLBACK(cb_ouvrir_FenAjoutUE), NULL);
    g_signal_connect(bouton_AjoutSalle_Admin, "clicked", G_CALLBACK(cb_ouvrir_FenAjoutESalle), NULL);
  g_signal_connect(FenAdmin, "delete-event", G_CALLBACK(cb_quit_application_admin), NULL);
}
void    connectSignal_FenAjoutEtu()
{
    g_signal_connect(bouton_valider_AjoutEtu, "clicked", G_CALLBACK(cb_valider_ajoutEtu), NULL);
    g_signal_connect(FenAjoutEtu, "delete-event", G_CALLBACK(cb_quit_fenAjoutEtu), NULL);
}
void    connectSignal_FenAjoutEns()
{
    g_signal_connect(bouton_valider_AjoutEns, "clicked", G_CALLBACK(cb_valider_ajoutEns), NULL);
    g_signal_connect(FenAjoutEns, "delete-event", G_CALLBACK(cb_quit_fenAjoutEns), NULL);
}
void    connectSignal_FenAjoutUE()
{
    g_signal_connect(bouton_valider_AjoutUE, "clicked", G_CALLBACK(cb_valider_ajoutUE), NULL);
    g_signal_connect(FenAjoutUE, "delete-event", G_CALLBACK(cb_quit_fenAjoutUE), NULL);
}
void    connectSignal_FenAjoutSalle()
{
    g_signal_connect(bouton_valider_AjoutSalle, "clicked", G_CALLBACK(cb_valider_ajoutESalle), NULL);
    g_signal_connect(FenAjoutSalle ,"delete-event", G_CALLBACK(cb_quit_fenAjoutSalle), NULL);
}

void cb_ouvrir_FenAjoutEtu()
{
    initFenAjoutEtu();
    connectSignal_FenAjoutEtu();
    gtk_widget_show_all(FenAjoutEtu);


}
void cb_ouvrir_FenAjoutEns()
{
    initFenAjoutEns();
    connectSignal_FenAjoutEns();
    gtk_widget_show_all(FenAjoutEns);
}
void cb_ouvrir_FenAjoutUE()
{
    initFenAjoutUE();
    connectSignal_FenAjoutUE();
    gtk_widget_show_all(FenAjoutUE);
}
void cb_ouvrir_FenAjoutESalle()
{
    initFenAjoutSalle();
  connectSignal_FenAjoutSalle();
  gtk_widget_show_all(FenAjoutSalle);
}

void    cb_valider_ajoutEtu()
{
    char*p_numEtu=calloc(20,sizeof(char));
    p_numEtu=(char*)gtk_entry_get_text (entry_numEtu_AjoutEtu);

    char*p_nomEtu=calloc(50,sizeof(char));
    p_nomEtu=(char*)gtk_entry_get_text (entry_nomEtu_AjoutEtu);

    char*p_prenomEtu=calloc(50,sizeof(char));
    p_prenomEtu=(char*)gtk_entry_get_text (entry_prenomEtu_AjoutEtu);

if(p_numEtu!=NULL &&p_nomEtu!=NULL && p_prenomEtu!=NULL)
{


    if(recEtuParCode(atoi(p_numEtu))==NULL)
        {
            Etu * etunew = creEtu(atoi(p_numEtu),p_nomEtu, p_prenomEtu);

                        Login * log=creLogin(p_numEtu,p_numEtu,1);
            ajouterLogin(log);
            ajouterEtu(etunew);
            detEtu(&etunew);
            detLog(&log);
            cb_quit_fenAjoutEtu();
        }
    else
        {
            GtkWidget *dialog;
            dialog = gtk_message_dialog_new_with_markup (  GTK_WINDOW(FenIdentification),
                     GTK_DIALOG_DESTROY_WITH_PARENT,
                     GTK_MESSAGE_ERROR,
                     GTK_BUTTONS_CLOSE,
                     "il existe deja !!!!");
            gtk_dialog_run (GTK_DIALOG (dialog));
            gtk_widget_destroy (dialog);
        }
}
    /*free();*/
}
void    cb_valider_ajoutEns()
{
    char*p_numEns=calloc(20,sizeof(char));
    p_numEns=(char*)gtk_entry_get_text (entry_numEns_AjoutEns);

    char*p_nomEns=calloc(50,sizeof(char));
    p_nomEns=(char*)gtk_entry_get_text (entry_nomEns_AjoutEns);

    char*p_prenomEns=calloc(50,sizeof(char));
    p_prenomEns=(char*)gtk_entry_get_text (entry_prenomEns_AjoutEns);

if(p_numEns!=NULL &&p_nomEns!=NULL && p_prenomEns!=NULL)
{


    if(recEnsParCode(atoi(p_prenomEns))==NULL)
        {
            Ens * ens = creEns(atoi(p_numEns),p_nomEns, p_prenomEns);
            Login * log=creLogin(p_numEns,p_numEns,2);
            ajouterEns(ens);
             ajouterLogin(log);
            detEns(&ens);
            detLog(&log);
            cb_quit_fenAjoutEns();
        }
    else
        {
            GtkWidget *dialog;
            dialog = gtk_message_dialog_new_with_markup (  GTK_WINDOW(FenIdentification),
                     GTK_DIALOG_DESTROY_WITH_PARENT,
                     GTK_MESSAGE_ERROR,
                     GTK_BUTTONS_CLOSE,
                     "il existe deja !!!!");
            gtk_dialog_run (GTK_DIALOG (dialog));
            gtk_widget_destroy (dialog);
        }
}
}
void    cb_valider_ajoutESalle()
{
     char*p_numSalle=calloc(20,sizeof(char));
    p_numSalle=(char*)gtk_entry_get_text (entry_numSalle_AjoutSalle);

    char*p_intitule=calloc(50,sizeof(char));
    p_intitule=(char*)gtk_entry_get_text (entry_IntituleSalle_AjoutSalle);

if(p_numSalle!=NULL &&p_intitule!=NULL )
{


    if(recSalleParCode(atoi(p_numSalle))==NULL)
        {
            Salle * salle = creSalle(atoi(p_numSalle),p_intitule);
            saveSalle(salle);
            detSalle(&salle);
            cb_quit_fenAjoutSalle();
        }
    else
        {
            GtkWidget *dialog;
            dialog = gtk_message_dialog_new_with_markup (  GTK_WINDOW(FenIdentification),
                     GTK_DIALOG_DESTROY_WITH_PARENT,
                     GTK_MESSAGE_ERROR,
                     GTK_BUTTONS_CLOSE,
                     "il existe deja !!!!");
            gtk_dialog_run (GTK_DIALOG (dialog));
            gtk_widget_destroy (dialog);
        }
}

}
void    cb_valider_ajoutUE()
{
    char*p_codeUe=calloc(20,sizeof(char));
    p_codeUe=(char*)gtk_entry_get_text (entry_codeUE_AjoutUE);

    char*p_intitule=calloc(50,sizeof(char));
    p_intitule=(char*)gtk_entry_get_text (entry_IntituleUE_AjoutUE);

    char*p_seq=calloc(50,sizeof(char));
    p_seq=(char*)gtk_entry_get_text (entry_SeqenceUE_AjoutUE);

if(p_codeUe!=NULL &&p_intitule!=NULL && p_seq!=NULL)
{


    if(recUEParCode(atoi(p_codeUe))==NULL)
        {
            UE * ue = creUE(atoi(p_codeUe),p_intitule, atoi(p_seq));
            ajouterUE(ue);
            detUE(&ue);
            cb_quit_fenAjoutUE();
        }
    else
        {
            GtkWidget *dialog;
            dialog = gtk_message_dialog_new_with_markup (  GTK_WINDOW(FenIdentification),
                     GTK_DIALOG_DESTROY_WITH_PARENT,
                     GTK_MESSAGE_ERROR,
                     GTK_BUTTONS_CLOSE,
                     "il existe deja !!!!");
            gtk_dialog_run (GTK_DIALOG (dialog));
            gtk_widget_destroy (dialog);
        }
}
}




/*****************************************************/

/*****************************************************/


/*Deploie l'interface correspondant au  fichiers XML                                                                         */
int main(int    argc,char**argv)
{
    /*test();*/
    gtk_init(&argc,&argv);
    deployerUI(argc,argv);
    gtk_main();

    return EXIT_SUCCESS;
}

/****************************************************************************************************************************/
